If the two header lines are always the first two lines, you could just discard the first two lines, like:
my $line = <$INPUT_FH>; $line = <$INPUT_FH>; while ($line = <$INPUT_FH>) { # process file }
Of course, that'll be a problem if you ever have a file with a missing header, or if the header repeats later on in the file. in that case, you could take advantage of the fact that the lines you want to keep always start with a number:
while (my $line = <$INPUT_FH>) { # Ignore all lines not beginning with a number next unless $line =~ /^\s*\d/; # process file }
If you have other lines that you want to keep that don't start with a number, though, then you'll have to match the lines and reject them:
while (my $line = <$INPUT_FH>) { # Ignore the header lines next if $line =~ /^(procs|\s*r\s+b\s+swpd)/; # process file }
In this case, you'll need to make your pattern complete enough to recognize the header and not reject the other lines you want to keep.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re: Removing matched pattern except the first pattern
by roboticus
in thread Removing matched pattern except the first pattern
by rahulruns
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |