in reply to Printing a int as hex

Since your hash values are decimal values (not hex strings), there is no need to use hex:
use warnings; use strict; my %hash = (x => 10); foreach my $x (keys %hash) { printf "%02x\n", $hash{$x}; } __END__ 0a