First of all, you should check that the addresses you want to match are valid. This has already been discussed recently in Matching an IP address. It's a bit more specific to check if one of your file entries is valid because it depends on the format you've chosen. For example, are 3 dots always needed? How many * signs are allowed, and where? Would *.*.*.255 be valid? And so on. However, with pattern matching and split you should be able to sort it out. Watch out if you split using . as a separator! It's a special character so you'll need to escape it.

Then it's a matter of a simple (internal) transformation on your file's contents: 128.10.*.* is almost a regular expression. All you need to do is escaping each dot with a backslash and substituting each * with [0-9]{1,3}

Then you should be able to match directly your transformed file entries with your addresses.

-- TMTOWTDI


In reply to Re: IP Verification Check System by trantor
in thread IP Verification Check System by LostS

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.