in reply to Deleting all the data after a specific position in a text file.

#! usr/bin/perl -w open(FILE,"<file1.txt"); my @lines=<FILE>; close(FILE); open(FILE,">file1.txt"); foreach $line(@lines) { if($line =~ /.*keywordhere.*/) { close(FILE); exit; } else { print FILE "$line"; } } close(FILE);
deffinately not better than truncate
was looking for something like this???
  • Comment on Re: Deleting all the data after a specific position in a text file.
  • Download Code