while ( read(FILE, $buf, 512) ) { $binhex = unpack "H*",$buf; # do something with $binhex }