Regexp::Common::net 2.120 review
DownloadRegexp::Common::net is a Perl module that provide regexes for IPv4 addresses. SYNOPSIS use Regexp::Common qw /net/;
|
|
Regexp::Common::net is a Perl module that provide regexes for IPv4 addresses.
SYNOPSIS
use Regexp::Common qw /net/;
while () {
/$RE{net}{IPv4}/ and print "Dotted decimal IP address";
/$RE{net}{IPv4}{hex}/ and print "Dotted hexadecimal IP address";
/$RE{net}{IPv4}{oct}{-sep => ':'}/ and
print "Colon separated octal IP address";
/$RE{net}{IPv4}{bin}/ and print "Dotted binary IP address";
/$RE{net}{MAC}/ and print "MAC address";
/$RE{net}{MAC}{oct}{-sep => " "}/ and
print "Space separated octal MAC address";
}
Please consult the manual of Regexp::Common for a general description of the works of this interface.
Do not use this module directly, but load it via Regexp::Common.
This modules gives you regular expressions for various style IPv4 and MAC (or ethernet) addresses.
$RE{net}{IPv4}
Returns a pattern that matches a valid IP address in "dotted decimal". Note that while 318.99.183.11 is not a valid IP address, it does match /$RE{net}{IPv4}/, but this is because 318.99.183.11 contains a valid IP address, namely 18.99.183.11. To prevent the unwanted matching, one needs to anchor the regexp: /^$RE{net}{IPv4}$/.
For this pattern and the next four, under -keep (See Regexp::Common):
$1
captures the entire match
$2
captures the first component of the address
$3
captures the second component of the address
$4
captures the third component of the address
$5
captures the final component of the address
Requirements:
Perl
Regexp::Common::net 2.120 keywords