| 1 | package PAR::Filter::Bleach; | ||
| 2 | use 5.006; | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use base 'PAR::Filter'; | ||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | PAR::Filter::Bleach - Bleach filter | ||
| 10 | |||
| 11 | =head1 SYNOPSIS | ||
| 12 | |||
| 13 | PAR::Filter::Bleach->apply(\$code); # transforms $code | ||
| 14 | |||
| 15 | =head1 DESCRIPTION | ||
| 16 | |||
| 17 | This filter removes all the unsightly printable characters from | ||
| 18 | your source file, using an algorithm similar to Damian Conway's | ||
| 19 | L<Acme::Bleach>. | ||
| 20 | |||
| 21 | =cut | ||
| 22 | |||
| 23 | sub apply { | ||
| 24 | my $ref = $_[1]; | ||
| 25 | |||
| 26 | $$ref = unpack("b*", $$ref); | ||
| 27 | $$ref =~ tr/01/ \t/; | ||
| 28 | $$ref =~ s/(.{9})/$1\n/g; | ||
| 29 | $$ref = q($_=<<'';y;\r\n;;d;y; \t;01;;$_=pack'b*',$_;$_=eval;$@&&die$@;$_)."\n$$ref\n\n"; | ||
| 30 | } | ||
| 31 | |||
| 32 | 1; | ||
| 33 | |||
| 34 | =head1 SEE ALSO | ||
| 35 | |||
| 36 | L<PAR::Filter> | ||
| 37 | |||
| 38 | =head1 AUTHORS | ||
| 39 | |||
| 40 | Audrey Tang E<lt>cpan@audreyt.orgE<gt> | ||
| 41 | |||
| 42 | You can write | ||
| 43 | to the mailing list at E<lt>par@perl.orgE<gt>, or send an empty mail to | ||
| 44 | E<lt>par-subscribe@perl.orgE<gt> to participate in the discussion. | ||
| 45 | Archives of the mailing list are available at | ||
| 46 | E<lt>https://www.mail-archive.com/par@perl.org/E<gt> or E<lt>https://groups.google.com/g/perl.parE<gt>. | ||
| 47 | |||
| 48 | Please submit bug reports to E<lt>https://github.com/rschupp/PAR-Packer/issuesE<gt>. | ||
| 49 | |||
| 50 | =head1 COPYRIGHT | ||
| 51 | |||
| 52 | Copyright 2003-2009 by Audrey Tang E<lt>cpan@audreyt.orgE<gt>. | ||
| 53 | |||
| 54 | This program is free software; you can redistribute it and/or modify it | ||
| 55 | under the same terms as Perl itself. | ||
| 56 | |||
| 57 | See F<LICENSE>. | ||
| 58 | |||
| 59 | =cut |