Acme-Buckaroo

 view release on metacpan or  search on metacpan

Buckaroo.pm  view on Meta::CPAN

"Cash for lithium", "Casper Lindley", "Cheryl Bloch", "Chris Casady", "Chris Collins", "Christopher Keith",
"Christopher Lloyd", "Chuck Cooper", "Clancy Brown", "Colette Emanuel", "Comic Book Hero", "Crying of Lot 49",
"Damon Hines", "Dena Fischer", "Dennis E. Jones", "Dennis Schultz", "Duck Hunter Bubba", "Duck Hunter Burt",
"Earl Mac Rauch", "Doctor Emilio Lizardo", "Tom Cranham", "Ron Gress", "New Jersey", "Sam Minsky",
"Doreen A. Dixon", "Eddie Marks", "Edward Morey", "Eric Guaglione", "Erik L. Nelson", "Francine Lembi",
"Frank James Sparks", "Fred Iguchi", "Fred J. Koenekamp", "Gary Bisig", "Gary Daigler", "Gary Hellerstein",
"Gary Hymes", "General Catburd", "George Bowers", "George Stokes", "Gerald Peterson", "Glenn Campbell",
"Gordon Ecker Jr.", "Greenlite", "Greg Mires", "Gregg C. Rudloff", "Gregory Jein", "Grovers Mills", "H. Bud Otto",
"Henry Millar", "Hoyt Yeatman", "J. Michael Riva", "Jacqueline Zietlow", "James Belohovek", "James Hagedorn",
"James Keane", "James M. McCann", "James Rosin", "James Saito", "Jamie Lee Curtis", "Jane Marla Robbins",
"Jane Schwartz Jaffe", "Jerry Lewis hope2carrion", "Jerry Segal", "Jessie Lawrence Ferguson", "Joan Rowe",
"John Bracken", "John David Ashton", "John Emdall", "John Gant", "John Gomez", "John Murray", "John O'Connor",
"John Parker", "John Roesch", "John Scheele", "John T. Reitz", "John T. VanVliet", "John Valuk", "John Vigran",
"John Walter Davis", "Jonathan Banks", "Judi Rosner", "Judith Herman", "Justin De Rosa", "Kathryn Newbrough Sommer",
"Katterli Frauenfelder", "Keith Shartle", "Kenneth Karman", "Kenneth Magee", "Kent Perkins", "Kevin Rodney Sullivan",
"Kolodny Brothers", "Larry Fallick", "Laura Harrington", "Layne Bourgoyne", "Leonard Gaines", "Leslie Ekker",
"Lewis Smith", "Linda DeScenna", "Linda Fleisher", "Linda Henrikson", "Lord John Whorfin", "M. James Arnett",
"Mariclare Costello", "Mark Freund", "Mark Homer", "Mark Stetson", "Masado Banzai", "Matt Clark", "Matthew Mires",
"Mic Rodgers", "Michael Bigelow", "Michael Boddicker", "Michael Evje", "Michael G. Nathanson", "Michael Hosch",
"Michael L. Fink", "Michael Neale", "Michael Runyard", "Michael Santoro", "Mike De Luna", "Mister Wizard",
"Mrs. E. Johnson", "Neil Canton", "Peggy Priddy", "Pepe Serna", "Peter Kuran", "Phone Phreakers", "R.J. Robertson",
"Radar Blazer", "Radford Polinsky", "Raye Birk", "Reed Morgan", "Richard Carter", "Richard L. Thompson",
"Richard Marks", "Rick Heinrichs", "Rick Taylor", "Robert Gray", "Robert Hummer", "Robert Ito",
"Robert Michael Steloff", "Robert Wilcox", "Roberto Terminelli", "Robin Dean Leyden", "Rocco Gioffre",
"Rock star", "Ronald Lacey", "Rosalind Cash", "Rug Sucker", "Sal Orefice", "Samurai", "Scott Beattie",
"Scott Squires", "Selma Brown", "Senator Cunningham", "Sherman Labby", "Sidney Beckerman", "Stephen Dane",
"Stephen Robinette", "Steve Burg", "Steve Grumette", "Steve Hellerstein", "Steve LaPorte", "Terry Liebling",
"Thomas Hollister", "Thomas Pynchon", "Thomas R. Polizzi", "Tom Southwell", "Tommy J. Huff", "Tony Rivetti",
"Vincent Schiavelli", "Virginia L. Randolph", "Wayne Fitzgerald", "William G. Clevenger",
"William L. Hayward", "William Reilly", "William Traylor");

# global variables.  Don't use these at home, boys and girls!
# semi-seriously, I should put these into a calling function, but it's such a bother.

my %xlate_2_hash    = ();
my %xlate_from_hash = ();


###############################################################################

sub translate
{
    # receives the string of the entire perl script after 'use Acme::Buckaroo'.

    my $in_string = shift;

    my $out = "";
    $out = Dumper($in_string);
    print("Instring=>>$out<<\n") if $debug_mode;

    my @in_array = split(//, $in_string);
    $out = Dumper(@in_array);
    print("in_array=>>$out<<\n")  if $debug_mode;

    my $i = 0;
    my @temparray = ();
    foreach my $thischar (@in_array)
    {
        # translate each character into it's ascii value.
        my $num = unpack("c", $thischar);
        # change that ascii value into a string from the array...
        my $newchar = $xlate_array[$num];
        print("char=>>$thischar<<, num=>>$num<<, newchar=>>$newchar<<\n")  if $debug_mode;
        print("char=>>%s<<, num=>>%s<<, newchar=>>%s<<\n", $thischar, $num, $newchar)  if $debug_mode;
        push(@temparray, "$newchar");
        $i++;
        if ($i > 3)
        {
            push(@temparray, "\n");
            $i = 0;
        }
    }

    my $out_string = $header . join("\t", @temparray) . "\n";
    print("out_string=>>$out_string<<\n")  if $debug_mode;
    return $out_string;

}

################################################################################
# Normalize is called to convert the text to perl again from the encoded version.
#

sub normalize
{
    my $in_string = shift;;

    $in_string =~ s/^$header//g;

    print("normalize, got in_string>>$in_string<<\n")  if $debug_mode;

    my %revhash = ();
    my $counter = 0;
    foreach my $this_elem (@xlate_array)
    {
        $revhash{$this_elem} = $counter++;
    }

    $in_string =~ s/\t\n/\t/g;
    $in_string =~ s/\t+/\t/g;
    my @in_array  = split(/[\t]/, $in_string);
    my $in_array_dump = Dumper(@in_array);
    print("in_array_dump=>>$in_array_dump<<\n")  if $debug_mode;

    my @translate_array = ();
    my $this_elem = "";
    $counter = 1;
    foreach $this_elem (@in_array)
    {
        if (!($this_elem)) { print("Found undefined elem, counter=$counter.\n"); $counter++; next; }
        my $ascii_num = $xlate_2_hash{$this_elem} || 0;
        my $to_char = pack("c", $ascii_num);
        printf("Normalized >>%s<<, ascii_num=>>%s<<, char=>>%s<<, counter=>>%s<<\n", $this_elem, $ascii_num, $to_char, $counter)  if $debug_mode;
        push(@translate_array, $to_char);
        $counter++;
    }

    my $outtext = join('', @translate_array);
    print("Converted back to text=>>$outtext<<\n") if $debug_mode;

    return("$outtext");

Buckaroo.pm  view on Meta::CPAN


}

###############################################################################

1;

###############################################################################

__END__

###############################################################################

=head1 NAME

Acme::Buckaroo - Buckaroo Banzai Characters Infest Your Code!

=head1 SYNOPSIS

Before Buckaroo-ing:

use Acme::Buckaroo;

print "Watch 'Buckaroo Banzai Across the 8th Dimension' Today!";

After Bucaroo-ing:

use Acme::Buckaroo;
Buckaroo Banzai Across The Eigth Dimension Buckaroo Banzai Across The Eigth Dimension
Bari Dreiband-Burman    General Catburd George Stokes   Frank James Sparks
        Gary Hellerstein        Glenn Campbell  Buckaroo Banzai Penny Priddy
        Damon Hines     New Jersey      Glenn Campbell  Doreen A. Dixon
        Francine Lembi  Buckaroo Banzai Girl Named John Scooter Lindley
        Gordon Ecker Jr.        Doreen A. Dixon Fred J. Koenekamp       New Jersey
        George Stokes   Gary Hymes      Gary Hymes      Buckaroo Banzai
        Scooter Lindley New Jersey      Gary Hellerstein        Grovers Mills
        New Jersey      Frank James Sparks      Buckaroo Banzai Sandra Banzai
        Doreen A. Dixon George Stokes   Gary Hymes      Gerald Peterson
        Gerald Peterson Buckaroo Banzai Glenn Campbell  Francine Lembi
        Edward Morey    Buckaroo Banzai Perfect Tommy   Glenn Campbell
        Francine Lembi  Buckaroo Banzai Smolensk USSR   Frank James Sparks
        Gary Daigler    Edward Morey    Gary Hellerstein        Gerald Peterson
        Frank James Sparks      Gary Hymes      Gary Hellerstein        Girl Named John
        Buckaroo Banzai Colette Emanuel Gary Hymes      Eddie Marks
        New Jersey      Gregory Jein    Defense Sec. McKinley   Penny Priddy
        Planet 10       Bari Dreiband-Burman

=head1 DESCRIPTION

The first time you run this program, the entire text of the program
after the 'use Acme::Buckaroo;' is converted (character by character)
into characters from the movie "Buckaroo Banzai Across the Eigth
Dimension" (and some other phrases, too).

The program will work (or not!) exactly as it did before it was
converted, but the code will be a somewhat endearing tribute to a
movie, instead of a clean, complete, clearly commented set of lines
of Perl code.

if you want to convert your program BACK into Perl, you must edit the
Acme::Buckaroo.pm module and turn on debugging (change the
line, "my $debug_mode = 0;" to the line, "my $debug_mode = 1;" and then
run the script again.  As it executes, it will translate the program
back.  Capture the output of this and you have your program back.

Acme::Buckaroo came about because the modules Acme::Buffy, Acme::Morse,
Acme::Pony, and Acme::Bleach were somewhat cryptically written.  This
author believes that CODE SHOULD BE SIMPLE and CLEAR to read and
understand.  Code that isn't clear is far less value.  And, since these
modules are for learning or FUN anyway, I might as well start here.

As someone who has taught beginners to use Perl, I've seen the problems
caused by using Perl idioms where typing a few more characters can make
maintenance possible and even quite easy.

=head1 DEDICATION

I'd like to dedicate this module to Mr. Damian Conway, who has bettered
Perl and the lives of those in the Perl-using community by vast amounts,
and continues to do good work.  Someday I'd like to buy him a beer.
Good book, dude!

The book, by the way, is "Object Oriented Perl", by Damian Conway
and Randall L. Schwartz, published by Manning Publications Company;
ISBN: 1884777791; (August 1999).

Also thanks to Jesse who reported a bug in this documentation
and introduced me to the CPAN bug tracking database, available
to everyone to report bugs in CPAN modules or scripts.  The address
for this is http://rt.cpan.org. If you know of a bug in a CPAN module,
report it there!

=head1 EXPORT

None by default.

=head1 SEE ALSO

Acme::Buffy, Acme::Morse, Acme::Pony, Acme::Bleach, and L<perl>.

=head1 DIAGNOSTICS

=over 4

=item C<Cannot Buckaroo '%s'>

Acme::Buckaroo could not modify the source file.  Are the file permissions set?

=item C<Cannot Buckaroo again on '%s'>

Acme::Buckaroo couldn't read the source file to execute it.  Are the file permissions set?

=back

=head1 AUTHOR

Kevin J. Rice, http://www.JustAnyone.com, E<lt>KevinRice@cpan.orgE<gt>

=head1 COPYRIGHT

Copyright (c) 2002, Kevin J. Rice.  All Rights Reserved. This module is



( run in 1.306 second using v1.01-cache-2.11-cpan-d06a3f9ecfd )