in reply to Re: bleach question
in thread bleach question
The code you provided is missing a step before the pack function. tr/ \t/01/; is needed to translate the spaces and tabs to 0's and 1's before pack can turn them into text.
Not so. The 'b' and 'B' pack templates only look at the least-significant bit of a character to be packed, so space (0x20) and '0' (0x30) translate | pack to a 0 bit, and \t (0x09) and '1' (0x31) to a 1 bit.
c:\@Work\Perl\monks>perl -wMstrict -le "for my $s (qq{\t \t \t \t }, '1000001001000010', 'qpppppqppqp +pppqp') { my $p = pack 'b*', $s; print qq{'$s' -> '$p'}; } " ' ' -> 'AB' '1000001001000010' -> 'AB' 'qpppppqppqppppqp' -> 'AB'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: bleach question
by Lotus1 (Vicar) on Sep 29, 2014 at 17:04 UTC |