sub hexstring($) { my @bytes = shift =~ /(.)/g; my $result = '0x'; foreach(@bytes) { $result .= sprintf "%02X", ord($_); } return $result; }