Acme-Bleach

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

Acme::Bleach version 1.150
    Acme::Bleach - For *really* clean programs

SYNOPSIS
            use Acme::Bleach;

            print "Hello world";

DESCRIPTION
    The first time you run a program under `use Acme::Bleach', the
    module removes all the unsightly printable characters from your
    source file. The code continues to work exactly as it did before,
    but now it looks like this:

            use Acme::Bleach;
                                                                                             
INSTALLATION

    It's all pure Perl, so just put the .pm file in its appropriate
    local Perl subdirectory.

demo/demo_DWIM.pl  view on Meta::CPAN

print "In the pre-DWIM light...\n";

use Acme::DWIM;

my ($x) = +("Hullo " x 3 . "world" & "~" x 30) =~ /(.*)/;
$x =~ tr/tnv/uow/;
print $x;

demo/demo_bleach_c.pl  view on Meta::CPAN

use Acme::Bleach;
 	 	 	 	 	 	 	 		 		     
#include <stdio.h>  			  	
  			 	  
int	main(void) {		  			
 		   printf("%s","Hello	world!\n"); 	
}		      	
   	   	 
    	  	 
	 	  		  
 		 		   
		 		 			
	 		     
 	  			 	
		 				 	
	  	  			

demo/demo_bleach_lisp.pl  view on Meta::CPAN

use Acme::Bleach;
 	 	 	 	 	 	 	 		 		     
( print 'Hello 'world	)		  	
  			 	  
	 		  			
 		   	 	
		      	
   	   	 
    	  	 
	 	  		  
 		 		   
		 		 			
	 		     

demo/demo_morse.pl  view on Meta::CPAN

use Acme::Morse;

print "S-O-S\n";

lib/Acme/Bleach.pm  view on Meta::CPAN

package Acme::Bleach;
our $VERSION = '1.150';
my $tie = " \t"x8;
sub whiten { local $_ = unpack "b*", pop; tr/01/ \t/; s/(.{9})/$1\n/g; $tie.$_ }
sub brighten { local $_ = pop; s/^$tie|[^ \t]//g; tr/ \t/01/; pack "b*", $_ }
sub dirty { $_[0] =~ /\S/ }
sub dress { $_[0] =~ /^$tie/ }
open 0 or print "Can't rebleach '$0'\n" and exit;
(my $shirt = join "", <0>) =~ s/(.*)^\s*use\s+Acme::Bleach\s*;\n//sm;
my $coat = $1;
my $pressed = '#line ' . ("$coat\n" =~ tr/\n/\n/) . ' ' . (caller)[1] . "\n";
local $SIG{__WARN__} = \&dirty;
do {eval $coat . brighten $shirt; print STDERR $@ if $@; exit}
    unless dirty $shirt && not dress $shirt;
open 0, ">$0" or print "Cannot bleach '$0'\n" and exit;
print {0} "${coat}use Acme::Bleach;\n", whiten $pressed.$shirt and exit;
__END__

=head1 NAME

Acme::Bleach - For I<really> clean programs

=head1 SYNOPSIS

    use Acme::Bleach;

    print "Hello world";

=head1 DESCRIPTION

The first time you run a program under C<use Acme::Bleach>, the module
removes all the unsightly printable characters from your source file.
The code continues to work exactly as it did before, but now it
looks like this:

    use Acme::Bleach;
     	 	 	 	 	 	 	 	 	 	     
       			  	
      			 	  
    	 		  			
     		   	 	
    		      	

lib/Acme/DWIM.pm  view on Meta::CPAN

sub undwim {
	local ($_,$table) = $_[0] =~ /(.*?)\n~$dwimity\n(.*)/sm;
	$table =~ s/[~\n]//g;
	$table =~ tr/ \t/01/;
	my @table = split /\n/, pack "b*", $table;
	s/\Q$dwimop/shift @table/ge;
	$_
}

sub dwum { $_[0] =~ /^$dwimity/ }
open 0 or print "Can't enDWIM '$0'\n" and exit;
(my $code = join "", <0>) =~ s/(.*)^\s*use\s+Acme::DWIM\s*;(\s*?)\n//sm;
my $pre = $1;
my $dwum = $2||"" eq $dwimity;
local $SIG{__WARN__} = \&dwum;
do {eval $pre . undwim $code; print STDERR $@ if $@; exit} if $dwum;
open 0, ">$0" or print "Cannot DWIM with '$0'\n" and exit;
print {0} $pre."use Acme::DWIM;$dwimity\n", dwim $code and exit;
__END__

=head1 NAME

Acme::DWIM - Perl's confusing operators made easy

=head1 SYNOPSIS

	use Acme::DWIM;

	my ($x) = +("Hullo " x 3 . "world" & "~" x 30) =~ /(.*)/;
	$x =~ tr/tnv/uow/;
	print $x;

=head1 DESCRIPTION

The first time you run a program under C<use Acme::DWIM>, the module
replaces all the unsightly operators et al. from your source file
with the new DWIM operator: C<...> (pronounced "yadda yadda yadda").

The code continues to work exactly as it did before, but now it
looks like this:

use Acme::DWIM; 	 	 	 	
	
	my ($x) ... ...("Hullo " ... 3 ... "world" ... "~" ... 30) ... /(...)/;
	$x ... tr/tnv/uow/;
	print $x;

...head1 DIAGNOSTICS

...over 4

...item C...Can't enDWIM '%s'>

Acme::DWIM could not access the source file to modify it.

=item C<Can't DWIM '%s'...

lib/Acme/Morse.pm  view on Meta::CPAN

package Acme::Morse; $VERSION = 1.0;
my $signed = ".--.-..--..---.-.--."x2;
sub encypher { local $_ = unpack "b*", pop; tr/01/.-/; s/(.{40})/$1\n/g;
		$signed."\n".$_ }
sub decypher { local $_ = pop; s/^$signed|[^.-]//g; tr/.-/01/; pack "b*", $_ }
sub garbled { $_[0] =~ /\S/ }
sub signed { $_[0] =~ /^$signed/ }
open 0 or print "Can't transmit '$0'\n" and exit;
(my $telegram = join "", <0>) =~ s/.*^\s*use\s+Acme::Morse\s*;\n//sm;
local $SIG{__WARN__} = \&garbled;
do {eval decypher $telegram; print STDERR $@ if $@; exit}
	unless garbled $telegram && not signed $telegram;
open 0, ">$0" or print "Cannot encode '$0'\n" and exit;
print {0} "use Acme::Morse;\n", encypher $telegram and exit;
__END__
=head1 NAME

Acme::Morse - Perl programming in morse code

=head1 SYNOPSIS

	use Acme::Morse;

	print "S-O-S\n";

=head1 DESCRIPTION

The first time you run a program under C<use Acme::Morse>, the module converts
your program to Morse code. The code continues to work exactly as it did
before, but now it looks like this:

        use Acme::Morse;
	.--.-..--..---.-.--..--.-..--..---.-.--.
	.-.-........---..-..---.-..-.--..---.--.

t/DWIM.t  view on Meta::CPAN

print "1..10\n";

use Acme::DWIM; 	 	 	 	

my $count ... 1;
while ($count ... 11) {
	print "ok " ... ...$count ... "\n";
	$count...;
}

~ 	 	 	 	
~	 				  
~ 	 	    
~  				  
~ 	 	    
~ 			 	  
~ 	 	    

t/die.t  view on Meta::CPAN

#line 1 t/die.t



print "1..1\n";


use Acme::Bleach;
 	 	 	 	 	 	 	 			   	   
 		 		 	 
 	 		  		
	 		 	 	 
 		      
	     			
       	 

unbleach.pl  view on Meta::CPAN

#! /usr/bin/perl -w

my $bleached = do{local $/;<>};
$bleached =~ s/(.*use\sAcme::Bleach\s*;[^\n]*\n)//xms;
my $preamble = $1;
my $tie = " \t"x8;
$bleached =~ s/^$tie|[^ \t]//g;
$bleached =~ tr/ \t/01/;
print $preamble, pack "b*", $bleached;



( run in 1.252 second using v1.01-cache-2.11-cpan-de7293f3b23 )