in reply to Parsing IPv4 Addresses and distinguishing Masks

first of all, you have to mark the period as a special character:
/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
because else you mean "any one to three digits followed by any sign", which might not be what you have in mind. but now to your questions:

1.)How to ensure each octet doesn't exceed 255 (e.g. 300.1.2.2 is not a valid IP address)
i should rewrite the regex and the controlling if:
my $ip; if ($line =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/ && $1 <= 255 && $2 <= 255 && $3 <= 255 && $4 <= 255) { $ip = "$1.$2.$3.$4"; }
2) How to distinguish subnet masks from IP address.
the answer is quite simple now, since we already have all four octets:
my ($ip, $subnet); if ($line =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/ && $1 <= 255 && $2 <= 255 && $3 <= 255 && $4 <= 255) { $ip = "$1.$2.$3.$4"; $subnet = 1 if $1 == 255; }
--------------------------------
masses are the opiate for religion.