I am reading each record from an input text file using the foreach
loop. Once my search of a pattern in a record is true - i want to skip
next n lines.
How do i get this done,
TIMTOWTDI, but my initial instinct is to use the "flip-flop" operator
(which is the .. operator used in scalar context). Read more about it
in
perldoc perlop
This program sets the number of lines to skip when a number is found.
When a number is found, that many lines are skipped. All others are
printed.
Paul Lalli
#!/usr/bin/perl
use strict;
use warnings;
#when find a number, skip the next five lines
my $skips = 4;
while (<DATA>){
next if (/\d/ .. !$skips--);
print;
$skips = 4;
}
__DATA__
one
two
three
Here's the 4th!
five
six
seven
eight
nine
ten
eleven
Another number: 12
thirteen
fourteen
fifteen
sixteen
seventeen
eightteen
nineteen