Acme-Buckaroo

 view release on metacpan or  search on metacpan

Buckaroo.pm  view on Meta::CPAN

# (and thus see lots of logging lines that explain how things are happening
# as they happen), set debug_mode = 1.
# If you do, you'll need either:
#   (1) Perl 5.6 (to get Data::Dumper by default), or
#   (2) to have Data::Dumper already installed.
# Data::Dumper is a very, very handy module, but it wasn't in the default Perl
# installation until (I think) Perl 5.6.  Perl 5.005 usually don't have it.
# Look on CPAN.ORG for Data::Dumper if you don't have it.
###############################################################################
my $debug_mode = 0;
print("starting script...\n") if $debug_mode;

if ($debug_mode)
{
    use Data::Dumper;
}
else
{
#    sub Dumper { return(""); }
}

Buckaroo.pm  view on Meta::CPAN

        return $in_string;
    }
    else
    {
        return 0;
    }
}

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

sub starts_with_header
{

    my $in_string = shift;
    my $retval = 0;

    print("In starts_with_header\n") if $debug_mode;

    if ($in_string =~ /^$header/)
    {
        return $in_string;
    }
    else
    {
        return 0;
    }

Buckaroo.pm  view on Meta::CPAN


    # elim anything before the 'use Acme::Buckaroo; line.
    $file_string =~ s/use\s*Acme::Buckaroo\s*;\s*\n//;

    print("Filestring=>>$file_string<<\n")  if $debug_mode;

    # no clue why we do this.  Anyone know?
    #local $SIG{__WARN__} = \&has_wordchars;

    if ( (has_wordchars($file_string)        ) &&
         (!(starts_with_header($file_string))) )
    {
        if (!(open(FILE_HANDLE, ">$0")))
        {
            print("Cannot Buckaroo '$0'\n");
            exit;
        }
        print("past open2...")  if $debug_mode;
        print(FILE_HANDLE "use Acme::Buckaroo;\n");
        my $result = translate($file_string);
        print(FILE_HANDLE $result);

Buckaroo.pm  view on Meta::CPAN

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.

README  view on Meta::CPAN

    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 $debugmode = 0;" to the line, "my $debugmode = 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.


SYNOPSIS

    Before Buckaroo-ing:



( run in 0.263 second using v1.01-cache-2.11-cpan-0d8aa00de5b )