Three suggestions spring to mind for combining the print statements, you could either combine the tests into one regular expression:
print "$_" if /\b12345\b| \b12346\b| \b20034\b| \b8787\b| \b31337\b| \b31338\b| \b54320\b| \b54321\b/x;
or combine the different regular expressions into one logical test:
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/);
or use a little loop:
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; } } }
(This idea for the last one was pinched from jcwren, implementation pinched from various others).

Nuance


In reply to RE: I want to be a Perl Jedi by nuance
in thread I want to be a Perl Jedi by dru145

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.