in reply to Re: Removing all lines from an array which match against a second array
in thread Removing all lines from an array which match against a second array
is broken. As soon as you've removed the first entry, your numbers will be off by one. Second entry, off by two, etc.$SYSLOG[$_] =~ $main_re and splice @SYSLOG, $_, 1 for 0 .. $#SYSLOG;
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.
|
|---|