2006/9/10, John Ackley <[EMAIL PROTECTED]>:
Trying to split class C IPs into network and host parts.
this works but I expected the host part in $2:
print "<$bu>\n" if $debug;
if( $bu =~ /^((\d+\.){3})(\d+)$/ ) {
print "$1 $2 $3\n" if $debug;
}
output:
<172.19.252.130>
172.19.252. 252. 130
where did my thinking jump the tract?
I do see three sets of ()
but the inner () was simply to group for the {3} count
where did the 252. come from? The last of 3 matches???
$1 is as I expected.
I think you wanted:
/^((?:\d+\.){3})(\d+)$/
$2 will match the last entry of $1, unles s you use (?:). Now, $1 should be
the first three octets, and $2 should be the last octet.
--
Igor Sutton Lopes
t: +55 51 9627.0779
e: [EMAIL PROTECTED]