in reply to Removing all lines from an array which match against a second array
That will will remove any elements in @SYSLOG that match any of the regexes in @REGEXPS. Or if you want a non-destructive versionmy $main_re = join '|', map "(?:$_)", @REGEXPS; my $idx = 0; while($idx <= $#SYSLOG) { splice( @SYSLOG, $idx, 1 ) and $idx-- if $SYSLOG[$idx] =~ $main_re; $idx++; }
my @KEEP = grep { not /$main_re/ } @SYSLOG;
_________
broquaint
updated: fixed first (and now second) example to be not broken (thanks to merlyn) and simplified second example
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Re: Removing all lines from an array which match against a second array
by merlyn (Sage) on Sep 26, 2003 at 14:15 UTC |