in reply to What is the best method to print hex string in bin-file?


You can just use pack 'H*' on the string as follows:
my $bin_str = pack 'H*', $hex_st;
Or in the case of your example, something like this:
... if ( $pngData{$hashCode} ) { open MyPNG, '>', $hashCode or die "Write Error: $hashCode: +$!\n"; binmode MyPNG; print MyPNG pack 'H*', $pngData{$hashCode}; close MyPNG; } ...
I often use this with qw() to keep the binary data nicely formatted:
my $bin_str = pack 'H*', join '', qw( 18 00 1B 00 21 00 00 01 0B 00 00 00 01 00 00 00 21 00 00 01 0B 00 00 00 01 00 00 00 18 00 1B 00 00 00 00 0D 3B 00 00 00 00 04 00 00 00 02 00 FF 00 01 0B 00 00 00 01 00 00 00 );

--
John.