PDA

View Full Version : Can you skip lines reading an infile in Perl?



Magic2K2
August 1st, 2001, 08:16
I do not need the first 3 lines of the data file I am attempting to manipulate. Previously, I had manually removed these lines. Is there a way for a script to do it?

Ted S
August 1st, 2001, 15:15
Very simple

foreach $line(@file_array){
if($line =~ /xxxx/){ next; }
elsif($line =~ /yyyy/){ next; }
elsif($line =~ /zzzz/){ next; }
else { print $line; }
}