Unpack() does the reverse of pack(): it takes a string representing a structure and expands it out into a list value, returning the array value. (In scalar context, it returns merely the first value produced.) The TEMPLATE has the same format as in the pack() function. (...) #### open(IMG,"foo.gif"); foreach () { # something wrong here I suppose @hex = unpack("H*",$_); foreach $b (@hex) { # this array on has one item print "$b "; # which gets printed here } # shouldn't it be a list? print "\n"; } close(IMG);