Thursday, July 30, 2009

How to delete a first word of each line in a file using perl?

it should delete a first word of each and every line in a file using perl commands

How to delete a first word of each line in a file using perl?
#!/usr/bin/perl -w





use strict;





open( INPUTFILE, "input.txt" ) || die "cannot open input file: $!\n" ;


open( OUTPUTFILE, "%26gt;output.txt") || die "cannot open output file: $!\n" ;


while(%26lt;INPUTFILE%26gt;) {


s/\w+\s//;


print OUTPUTFILE "$_";


}


close(INPUTFILE);


close(OUTPUTFILE);


exit 0;


No comments:

Post a Comment