./c0de/perl/ip2hex.txt

0.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
 
#!/usr/bin/perl
use strict;
my $ip = shift;
 
die("no ip was provided\n") unless $ip;
 
my @octets = split(/\./, $ip);
 
print "hex version of $ip is: 0x";
foreach my $octet(@octets) {
   $octet =~ s/$octet/sprintf("%X",$octet)/eg;
   print $octet
}
print "\n"; 

Back