in reply to IP operation trouble

It's because $binaddr only lives within the eval block. Ditch the eval block and you should be ok.

Update:
I fiddled with it a little just because I've never really messed with binary operations.

#!/usr/local/bin/perl -w use strict; use Net::IP qw/:PROC/; # # create your Net::IP object # my $ip_addr = Net::IP->new( "192.168.0.20" ); # # $ip_int becomes a Math::BigInt object # my $ip_int = ip_bintoint( $ip_addr->binip ); print "IP Address: ", $ip_addr->ip, "\nBin: ", $ip_addr->binip, "\nInt: ", $ip_int->numify(), "\n"; # # turn the Integer into a vanilla scalar # my $int_ip = $ip_int->numify(); # # Now start from the integer and go backwards # my $bin_from_int = sprintf( "%b", $int_ip); my $ip_from_bin = ip_bintoip( $bin_from_int, 4); print "\n\nInt: $int_ip\n", "Bin: $bin_from_int\n", "IP: ", $ip_from_bin, "\n";

--
"This alcoholism thing, I think it's just clever propaganda produced by people who want you to buy more bottled water." -- pedestrianwolf

Replies are listed 'Best First'.
Re^2: IP operation trouble
by fauria (Deacon) on Jan 12, 2005 at 14:27 UTC
    Hi there, The purpose of the eval block was to ensure there was not any error in the function, without it there happens the same. Thanks anyway