Finally I finished this program like this...
$inputfile= shift; $outputfile = shift; open(FILE1,"<$inputfile"); @lines=<FILE1>; close(FILE1); open(FILE2,">$outputfile"); foreach $line (@lines) { if($line =~ m/(\d+) ([a-z,A-Z,_,0-9]+)/) /* to write this line I have taken lot of time as I know basics in Regular Expressions */ { print FILE2 "$2 $1\n"; } } close(FILE2); print "\n" Thanks to all who helped me to solve this problem... -----Original Message----- From: Chris Devers [mailto:[EMAIL PROTECTED] Sent: Friday, October 14, 2005 6:59 PM To: Sreedhar reddy Cc: beginners@perl.org Subject: RE: I need help here You accidentally replied just to me, not to the list. Please don't do that. Send all messages to the list and I will read them there, along with all the other helpful list subscribers. On Fri, 14 Oct 2005, Sreedhar reddy wrote: > I tried like this... > > INPUT = fopen("filename"); > OUTPUT -- I opened another file here to write output > > while(<INPUT>) { > chomp @_; > @strings = split(@_, " "); > print OUTPUT strings[1] + strings[0]; > } > > > But I got error [message]...Can [you] modify this program if it is > correct??? If it's correct, it doesn't need to be modified, does it? :-) If you want help with your errors, you need to *tell us what the error message was*! Is the text above literally what you wrote? If so, it can't work -- INPUT isn't a valid variable name (it needs to have a 'sigil', like $, @, or %) and the "OUTPUT -- I..." line just looks like a comment. I assume that isn't really your code, is it? Please show the list exactly what you're doing and what's happening when you try to do it: what the exact statements are to declare your input and output files are, what the while{} loop is (this appears complete, but I want to be sure), and what the error message was. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>