Carl-Joseph has asked for the wisdom of the Perl Monks concerning the following question:
I think I may have found a problem with Perl's pack function. Here is the code:
use strict; my @bits = ( "0001", "0010", "0011", "0100", "0101" ); my @out_data; my $idx; foreach my $bitval ( @bits ) { $out_data[ $idx++ ] = pack( "b4", $bitval ); } open( OUT, ">d:\\tmp\\hex_out.txt" ); select( OUT ); print @out_data; close( OUT );
I get the following set of bytes in the output file:
08 04 0c 02 0d 0a
Notice the (gratuitous?) "0d". I cannot figure out why I am getting that byte.
Thanks,
Carl-Joseph
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with Pack
by Corion (Patriarch) on Sep 22, 2000 at 11:39 UTC | |
by jcwren (Prior) on Sep 22, 2000 at 17:54 UTC | |
by tilly (Archbishop) on Sep 23, 2000 at 13:08 UTC | |
|
Re: Problem with Pack
by princepawn (Parson) on Sep 22, 2000 at 18:10 UTC |