Acme-AsciiArtinator
view release on metacpan or search on metacpan
lib/Acme/AsciiArtinator.pm view on Meta::CPAN
# run ASCII Artinization on a picture and a code string.
#
sub asciiartinate {
my %opts = @_;
if (@_ == 1 && ref $_[0] eq "HASH") {
%opts = @{$_[0]};
}
my ($PIC, $CODE, $OUTPUT);
if (defined $opts{"debug"} && $opts{"debug"}) {
$DEBUG = 1;
}
if (defined $opts{"art_file"}) {
my $fh;
local $/ = undef;
open($fh, "<", $opts{"art_file"}) || croak "Invalid art_file specification: $!\n";
$PIC = <$fh>;
close $fh;
} elsif (defined $opts{"art_string"}) {
lib/Acme/AsciiArtinator.pm view on Meta::CPAN
}
#
# can run from command line:
#
# perl Acme/AsciiArtinator.pm [-d] art-file code-file [output-file]
#
if ($0 =~ /AsciiArtinator.pm/) {
my $debug = 0;
my $compile_check = 1;
my @opts = grep { /^-/ } @ARGV;
@ARGV = grep { !/^-/ } @ARGV;
foreach my $opt (@opts) {
$debug = 1 if $opt eq '-d';
# $compile_check = 1 if $opt eq '-c';
}
asciiartinate( art_file => $ARGV[0] ,
code_file => $ARGV[1] ,
output => $ARGV[2] || "ascii-art.pl",
debug => $debug ,
'compile-check' => $compile_check );
}
1;
__END__
=head1 NAME
Acme::AsciiArtinator - Embed Perl code in ASCII artwork
lib/Acme/AsciiArtinator.pm view on Meta::CPAN
in the artwork of your choice. In no particular order,
here are some suggestions:
=over 4
=item * Make sure the original code works
Make sure the code compiles and test it to see if it
works like you expect it to
before running the ASCII Artinator. It would be frustrating to
try to debug an artinated script only to later realize that
there was some bug in the original input.
=item * Get rid of comments
This module won't handle comments very well. There's no way
to stop the ASCII Artinator from splitting your comment across
two lines and breaking the code.
=item * Reduce whitespace
lib/Acme/AsciiArtinator.pm view on Meta::CPAN
Specifies the output file for the embedded code. If omitted,
output is written to the file "ascii-art.pl" in the current
directory.
=item compile_check => 0 | 1
Runs the Perl interpreter with the C<-cw> flags on the
original code string and asserts that the code compiles.
=item debug => 0 | 1
Causes the ASCII Artinator to display verbose messages
about what it is trying to do while it is doing what it
is trying to do.
=item test_argv1 => [ @args ], test_argv2 => [ @args ] , test_argv3 => ...
Executes the original and the artinated code and compares the output
to make sure that the artination process did not change the
behavior of the code. A separate test will be conducted for
( run in 1.345 second using v1.01-cache-2.11-cpan-49f99fa48dc )