in reply to Re: Re: Can you spot the problem?
in thread Can you spot the problem?

You can match an IP-address with a regexp, just don't try to roll your own, do  {use Regexp::Common; /$RE{net}{IPv4}/} instead.

Replies are listed 'Best First'.
Re: Re: Re: Re: Can you spot the problem?
by hardburn (Abbot) on Mar 05, 2004 at 22:21 UTC

    From the Regexp::Common::net docs:

    $RE{net}{IPv4}

    Returns a pattern that matches a valid IP address in "dotted decimal"

    So it only matches the traditional dotted-quad form of IPv4 addresses. That's just one format IPv4 can come in (albeit the most common). There are modifiers Regexp::Common allows for some other formats (like "dotted hex"), but not all possible formats (a simple 32-bit number, for example).

    ----
    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

      There are modifiers Regexp::Common allows for some other formats (like "dotted hex"), but not all possible formats (a simple 32-bit number, for example).
      Yeah, it's true that IP addresses can be given as a 32-bit number, and while I've encountered such IP addresses many times, it's always as data in a program, or binary data between programs. I've never found myself parsing 32 bit numbers out of a file, to get the IP address.

      Abigail