On 2012-03-13 18:17:26, MOB wrote:
Show quoted text> The apply method PAR::Filter::Bleach is missing a step that makes the
> whole package useless (unless the purpose of the package is to make code
> unrunnable, in which case it is fine ;-) ).
Nope, it works (at least with Perl 5.8.8, 5.10.1, 5.12.3).
Show quoted text> Before the "pack" statement in
> $_=<<'';y;\r\n;;d;$_=pack'b*',$_;$_=eval;$@&&die$@;$_
> you need to convert the input string from whitespace back to binary
> digits:
> $_=<<'';y;\r\n;;d;y; \t;01;;$_=pack'b*',$_;$_=eval;$@&&die$@;$_
This looks reasonable, but the original statement works :)
It took me a couple minutes to figure out why e.g.
pack "b*", "\t \t "
returns "A". Here's a snippet from the perl source
(Perl 5.12.3, file pp_pack.c, function S_pack_rec):
while (l++ < len) {
if (*str++ & 1)
bits |= 0x80;
if (l & 7)
bits >>= 1;
else {
PUSH_BYTE(utf8, cur, bits);
bits = 0;
}
}
(str points to the string to pack).
All that matters about the bytes to pack is their
least significant bit: 0 for '0', 1 for '1),
but also 0 for ' '=0x20, 1 for '\t'=0x09.
So technically, there's nothing wrong with the code,
but I'll apply the patch anyway, just for the fun moment
I had while pondering it.
Cheers, Roderich