sub as_hexstr { local $_=shift; my $hexstr=""; foreach (split //) { $hexstr.=sprintf"02X",ord; } return $hexstr; } while (<>) { print as_hexstr($_); }