#!/usr/bin/perl -w use strict; my @octets = split(/\./, $ENV{'REMOTE_ADDR'}); pop(@octets); my @hexval; push(@hexval, dec2hex($_)) for (@octets); my $hex = join("", @hexval); print "Content-type: text/html; charset=ISO-8859-1\n\n"; print "The hex value is: $hex\n"; sub dec2hex { my $decnum = shift; my ($hexnum, $modulus, @hexval); $hexnum = int($decnum / 16); $hexnum = chr($hexnum + 55) if ($hexnum > 9); push(@hexval, $hexnum); $modulus = $decnum % 16; $modulus = chr($modulus + 55) if ($modulus > 9); push(@hexval, $modulus); return join("", @hexval); }