in reply to I want to be a Perl Jedi
or combine the different regular expressions into one logical test:print "$_" if /\b12345\b| \b12346\b| \b20034\b| \b8787\b| \b31337\b| \b31338\b| \b54320\b| \b54321\b/x;
or use a little loop:print "$_" if (/\b12345\b/ or /\b12346\b/ or /\b20034\b/ or /\b8787\b/ or /\b31337\b/ or /\b31338\b/ or /\b54320\b/ or /\b54321\b/);
(This idea for the last one was pinched from jcwren, implementation pinched from various others).my @ports = map { qr/$_/ } ("\b12345\b", "\b12346\b", "\b20034\b", "\b8787\b", "\b31337\b", "\b31338\b", "\b54320\b", "\b54321\b"); while (<FWLOG>) { for my $port (@ports) { if ($_ =~ $port) { print; last; } } }
Nuance
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: I want to be a Perl Jedi
by jlistf (Monk) on Jul 18, 2000 at 17:49 UTC | |
by jcwren (Prior) on Jul 18, 2000 at 18:01 UTC |