in reply to Regex question
Keep an array of the last lines read:
#!/usr/bin/perl use Getopt::Std; my %o; getopt 'b:a:',\%o; my $pat = shift; my @last; while(<>) { if (/$pat/) { @last = (); <> for 1..$o{a}; next; } push @last, $_; print shift @last if $o{b} < @last; } print @last;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex question
by ikegami (Patriarch) on Jan 26, 2009 at 13:15 UTC | |
by shmem (Chancellor) on Jan 26, 2009 at 14:34 UTC |