Here's one way to easily store and edit the numbers. You could also store them in a separate file, but I like the DATA trick better. Either way, the list can easily be maintained by others who may not know about regexp or perl code:

#!/bin/nsperl use strict; my $trojanfile = "trojan.log"; ## At the top makes it easier to find i +f it is changed ## Read in all the port numbers my %number; while(<DATA>) { /^#/ and next; ## Skip lines starting with '#' /(\d+)/ and $number{$1}++; ## Hash eliminates doubles gracefully } my $findport; for (sort {$a <=> $b} keys %number) { ## Sort makes it easier to read $findport .= "$_|"; } chop $findport; ## Yes, this is chop, not chomp! open (FILEOUT, ">$trojanfile") or die "Can't open $trojanfile: $!\n"; print FILEOUT "Searched for: $findport\n"; ## Slow but succinct: (my $logfile=`date +%d%b%Y` . ".elog") =~ s/\n//; open (FWLOG, "$logfile") or die "Can't open $logfile: $!\n"; while(<FWLOG>){ print FILEOUT if (/\b(?:$findport)\b/o); ## nice call ferrency } close(FWLOG); exit; __DATA__ ## This is the list of ports ## Lines with a '#" at the start are comments ## Everything else is a port number to check for ## Even embedded comments are okay, just have the number go first 12345 12346 31337 ## Default back orifice port 8787 ## Other comments here 1823 This is a comment too, but without the nice '#' 88776

In reply to Re: I want to be a Perl Jedi by turnstep
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.