in reply to RE: Why, what, where to unpack?! (was: Files, unpack and text values)
in thread Files, unpack and text values

You are absolutely right! That did the trick... This is what I turned up with to get it looking somewhat with my hex editors output:
open IMG, "foo.gif" or die "Couldn't open image: $!\n"; undef $/; $image = <IMG>; $hex = unpack("H*", $image); close IMG; while ($txt = substr($hex,0,32,'')) { $txt =~ s/(..)/$1 /g; print $txt."\n"; }
Now all I have to do is figure out where those extra bytes went (the results are still not exactly the same), and who's goofing up on this one. I bet you its the editor...

#!/home/bbq/bin/perl
# Trust no1!
  • Comment on RE: RE: Why, what, where to unpack?! (was: Files, unpack and text values)
  • Download Code

Replies are listed 'Best First'.
RE: RE: RE: Why, what, where to unpack?! (was: Files, unpack and text values)
by mdillon (Priest) on Jun 26, 2000 at 07:18 UTC
    the slurp/unpack method does not lose any bytes. i checked my code's round-trip integrity with cmp(1) like so:
    [mike@prometheus ~]$ perl -e 'undef $/; open IMG, "foo.gif"; print pack("H*", unpack("H*", <IMG>));' | cmp foo.gif -