in reply to Removing all lines from an array which match against a second array

Just conglomerate your regexes into a single regex and splice out the undesired elements e.g
my $main_re = join '|', map "(?:$_)", @REGEXPS; my $idx = 0; while($idx <= $#SYSLOG) { splice( @SYSLOG, $idx, 1 ) and $idx-- if $SYSLOG[$idx] =~ $main_re; $idx++; }
That will will remove any elements in @SYSLOG that match any of the regexes in @REGEXPS. Or if you want a non-destructive version
my @KEEP = grep { not /$main_re/ } @SYSLOG;

HTH

_________
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
    The code
    $SYSLOG[$_] =~ $main_re and splice @SYSLOG, $_, 1 for 0 .. $#SYSLOG;
    is broken. As soon as you've removed the first entry, your numbers will be off by one. Second entry, off by two, etc.

    Two ways to fix. Insert reverse after for (do them backwards), or just use a grep:

    @SYSLOG = grep !/$main_re/, @SYSLOG;

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.