Acme-AsciiArtinator
view release on metacpan or search on metacpan
lib/Acme/AsciiArtinator.pm view on Meta::CPAN
}
$bc -= $tt;
#
# for regular Perl variables ( "$x", "@bob" ), it is OK to split
# the sigil and the var name with any whitespace ("$ x", "@\n\tbob").
# For special Perl vars ( '$"', "$/", "$$" ), it is OK to split
# with spaces and tabs but not with newlines.
#
# Check for this condition here and say that padding is needed if
# a special var is currently aligned on a newline.
#
if ($bc == 0 && $blocks[$ib] == 0 && $tokens[$it] eq "\$"
&& $contexts[$it] eq "SIGIL" && $contexts[$it+1] eq "name"
&& length($tokens[$it+1]) == 1 && $tokens[$it+1] =~ /\W/) {
warn "\$tt > \$bc but padding still needed: \n",
(join " : ", @tokens[0 .. $it+1]), "\n",
(join " : ", @contexts[0 .. $it+1]), "\n",
(join " : ", @blocks[0 .. $ib+1]), "\n";
lib/Acme/AsciiArtinator.pm view on Meta::CPAN
to align, any whitespace in your code will be printed out as
space over a darkspace in the art and put a "hole" in your
picture. It would be nice if there was a way to align the
whitespace in the code with the whitespace in the art, but that
is probably something for a far future version.
=item * Avoid significant newlines
Newlines are stripped from the code before the code is tokenized.
If there are any significant newlines (I mean the literal 0x0a char.
It should still be OK to say C<print"\n">), then the artinated
code will run differently.
=item * Consider workarounds for quoted strings
Quoted strings are parsed as a single token. Consider ways to break
them up so that can be split into multiple tokens. For example, instead
of saying C<$h="Hello, world!";>, we could actually say something like:
&I;($c,$e)=qw(, !);$h=H.e.l.l.o.$c.$".W.o.r.l.d.$e;
The modified code is a lot longer, but this code can be split at any
point except in the middle of C<qw>, so it is much more flexible code
from the perspective of the Artinator.
=item * Perform some smart reordering
In the spider example, we see that the largest contiguous blocks of
( run in 1.286 second using v1.01-cache-2.11-cpan-8dfa8b56332 )