#!/home/toma/perl5i/bin/perl
#
# Program to restore a bleached Perl program.
#
# Copyright (c) 2001, Tom Anderson. All Rights Reserved.
# This module is free software. It may be used, redistributed
# and/or modified under the terms of the Perl Artistic License
# (see http://www.perl.com/perl/misc/Artistic.html)
#
# Based on Bleach.pm, Copyright (c) 2001, Damian Conway
# This program is available at http://tomacorp.com/perl/rit/index.html
#
use Getopt::Std;
getopt('f:');
our $opt_f;
if ($opt_f eq "")
{
print "Usage: Rit.pl -f bleached_code.pl\n";
exit
}
open(FN, $opt_f) or die "Can't open $opt_f";
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/ }
(my $shirt = join "", <FN>) =~ s/.*^\s*use\s+Bleach\s*;\n//sm;
print brighten $shirt;