Sandy lone wrote:
I need to translate an IP addr with its mask from this form:
192.168.1.30/255.255.255.0
to this one:
192.168.1.30/24
One way to do it:
$ perl -le'
use Socket;
my $stuff = "192.168.1.30/255.255.255.0";
my ( $ip, $mask ) = split /\//, $stuff;
print "$ip/" . unpack "%32b*", inet_aton $mask;
'
192.168.1.30/24
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/