http://www.perlmonks.org?node_id=1021346

mark4444az has asked for the wisdom of the Perl Monks concerning the following question:

I'm novice level and in a little over my head on this one. I have some code (run from cygwin)where I unpack a bin file to a text file:
open (OUTFILE, ">bin.txt") or die "Can't open new text file! \n" , &cl +ean_up; # Make temp text file to unpack the bin file open (INFILE, "$bin_file_name") or die "Can't open nvm file! \n" , + &clean_up; # Open nvm binary file #### This unpacks the binary file and puts it in a text file bin.t +xt #### my @lines = unpack ("W*", <INFILE>); my $line; foreach $line (@lines) { print OUTFILE sprintf("%02X", $line); } close (OUTFILE); close (INFILE);
The &clean_up sub just removes files and that works fine. The problem I have is when I unpacked a bin file it stopped printing on 0x0A, which is an ascii line feed. I changed it to an 0x0B and it worked fine. This makes me think that my printout is content sensitive, which would be BAD. I further suspect that the W* may be the wrong way to go on this. Any suggestions?