my $hex = sprintf("%x", '0000000011100000011'); or my $hex = unpack "I", '0000000011100000011'; $hex = sprintf("%x", $hex);