Thank you for the example, it's good!

You have only to copy this line ...

my $IPs="(1.1.1.1|192.168.1.1|10.10.10.10)"; #notice the '|' as a different option to compare

And replace I WANT TO GREP FROM IP.TXT for $IPs.

And the last $file should be $filename.

Please, try it!

Listen, if you are learning all this, but you don't understand it, you are loosing your precious time.

You should undertand all these so well that you might write it in a different manner a lot of times... (if you want to do of this learning something useful, not because of anybody)

If you need to read the IPs from a file, just imagine that it is another text file, and read it the same as any log file. Then keep the IP values.

Use this practice to create a game, or something that you need and don't want to spend a lot of time writing. Something funny, or original.


In reply to Re: How can I grep these IP-addresses from these logfiles? by chanio
in thread How can I grep these IP-addresses from these logfiles? by Anonymous Monk

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.