in reply to Converting between network and dotted quad. Issue with << and >> operators between Perl Versions.

Perhaps your 5.8.8 uses 64bit integers. Try the following:

sub network_to_dotted_quad { my ($address) = @_; return sprintf ("%d.%d.%d.%d", $address >> 24, ($address >> 16) & 255, ($address >>8) & 255, $address & 255); }
  • Comment on Re: Converting between network and dotted quad. Issue with << and >> operators between Perl Versions.
  • Download Code

Replies are listed 'Best First'.
Re^2: Converting between network and dotted quad. Issue with << and >> operators between Perl Versions.
by RoyCrowder (Monk) on Apr 13, 2009 at 17:41 UTC
    zwon, thanks much! My sys admins just transferred our app to a new box and didn't tell me they installed 64bit. You were correct! Thanks again for your help!! Thanks to everyone for their input!

    The Web is like a dominatrix. Everywhere I turn, I see little buttons ordering me to Submit. (Nytwind)
      Like I mentioned in the CB, you reinvented inet_aton and inet_ntoa.
      use Socket qw( inet_aton inet_ntoa ); sub dotted_quad_to_network { return unpack 'N', inet_aton $_[0] } sub network_to_dotted_quad { return inet_ntoa pack 'N', $_[0] }