On Fri, 28 Jan 2005, Anish Kumar K. wrote: > Say I have a string called returned from the text file.. > Hi $name- welcome to the world of $Logs. Country is $country. Time is $time > I am getting this from the text file and then in the program > I am printing this out. with its correponding values..
Hi Anish, Try something before you post a message, do not expect people here to solve your homework, anyway the following code might work for you if the input file is in the following format. Senthil Perl India 13:12 Anish Python India 12:00 Kumar S C++ USA 11:00 Begin Code #!/usr/bin/perl open (IN,"<names") || die "Cannot open input file:$!"; open (OUT,">named_list") || die "Cannot open output file:$!"; @names=<IN>; chomp(@names); for($i=0; $i < $#names; $i= $i+4){ print OUT "Hi $names[$i], Welcome to $names[$i+1], Country is $names[$i+2] and the time is $names[$i+3]\n"; } End Code Regards, Senthil -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>