in reply to open a binary file for hexadecimal manipulation
You can convert binary strings to hexadezimal representation (i.e. text strings) and back using the Perl functions pack() and unpack(). There are a little confusing - I personally have problems to remember which does which way conversation - but very powerful. See perldoc for the details and you will definitely find a tutorial on the web how to use it.
The code should look like this (untested):
open(IN, '<', $ifilename); binmode(IN); while (!eof IN) { read(IN, my $binstring, $length); my $hexstring = unpack("...", $binstring); } [...] my $newbin = pack("...", $hexstring);
Please note that pack() awaits a list of arguments...
Update:
See this tutorial. Direct at the start it shows how to do bin2hex and hex2bin!
|
|---|