in reply to decimal -> hex

As I have commented before I am of the opinion that splitting your textual IP address is the same as parsing CGI using your own hand-rolled routines. It's dirty. It's bad. It might work.
use Socket; my $ip_hex = join('.', map { sprintf("%02X", ord($_)) } split(//, inet_aton($addr))); my $ip_dec = join('.', map { hex($_) } split(/\./, $ip_hex));
The nice thing about inet_aton is that it works even with text names like "www.xyzco.com".