in reply to ntohl() in perl

As nothingmuch suggested:
sub ntohl { pack("L", unpack("N", $_[0])); } sub ntohs { pack("S", unpack("n", $_[0])); } sub htonl { ntohl(@_); } sub htons { ntohs(@_); }
Remember that on some systems there is no difference between "Network" and "Host" order. Using reverse is irresponsible.

This is all mostly irrelevant anyway, since standard modules like IO::Socket take care of it all for you automatically.

Replies are listed 'Best First'.