Subject: | Can you parse "parse address<space>netmask" |
This is to forward on a request from a Debian user.
a typically formatting of ip addresses with netmasks in the cisco world
is address<space>netmask. NetAddr::IP already knows about
address and netmask seperated by "/" so seperating by " " should
be straight forward.
something like this solves it although i have no idea about the
implications ... Havent run the testsuite ...
--- NetAddr/IP/Lite.pm.orig 2008-12-15 11:18:53.000000000 +0100
+++ NetAddr/IP/Lite.pm 2008-12-15 11:19:00.000000000 +0100
@@ -516,7 +516,7 @@
while (1) {
unless (@_) {
- if ($ip =~ m!^(.+)/(.+)$!) {
+ if ($ip =~ m!^(.+)[/ ](.+)$!) {
$ip = $1;
$mask = $2;
} elsif (grep($ip eq $_,qw(default any broadcast loopback
unspecified))) {
perl -e 'use NetAddr::IP; $i=new NetAddr::IP "10.0.0.1 255.255.255.0" or
die; print $i->addr . "\n"'
10.0.0.1
The bug report is at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=508775