mark4444az has asked for the wisdom of the Perl Monks concerning the following question:
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?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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unpack Bin file problem
by bart (Canon) on Mar 01, 2013 at 21:38 UTC | |
by mark4444az (Sexton) on Mar 01, 2013 at 22:36 UTC | |
by bart (Canon) on Mar 01, 2013 at 23:37 UTC | |
by mark4444az (Sexton) on Mar 04, 2013 at 15:58 UTC |