Acme-EyeDrops
view release on metacpan or search on metacpan
demo/sightly.pl view on Meta::CPAN
This creates myprog2.pl, equivalent to the original
myprog.pl, but prettier and shaped like a camel.
sightly -p -r 1 -s window -z "Bill Gates is a pest!\n" >bill.pl
This creates bill.pl, a program that prints the above string.
sightly -g 3 -bps camel,mongers -f some_binary_file >eyesore
This creates eyesore, a sightly-encoded file.
To decode it: perl eyesore > f.tmp
To check it worked: cmp f.tmp some_binary_file
Notes:
If no shape is specified, a single (very long) line will be output.
If a shape, but no file, is specified, a default no-op filler will
be used to fill the shape.
EOM
exit 1;
}
sub list_shapes {
my @builtin = Acme::EyeDrops::get_builtin_shapes();
my @eye = Acme::EyeDrops::get_eye_shapes();
print "builtin shapes : @builtin\n";
print ".eye file shapes: @eye\n";
lib/Acme/EyeDrops.pm view on Meta::CPAN
Apart from reducing the (key-)stroke count, you must avoid regexes
and strive to replace alphanumeric characters with sightly ones,
which do not require sightly encoding.
To illustrate, consider the intriguing problem of creating
I<Buffy looking in the mirror>. Let's start with F<k.pl>:
open$[;chop,($==y===c)>$-&&($-=$=)for@:=<0>;
print$"x-(y---c-$-).reverse.$/for@:
Notice that EyeDrops-generated programs, by default, contain no
trailing spaces, which complicates the above program.
Buffy looking in the mirror can now be created with:
sightly.pl -r 1 -f k.pl -s buffy2 >b.pl
cat b.pl (should show Buffy's face)
perl b.pl (should show Buffy looking in the mirror)
Drat. This requires two I<buffy2> shapes. What to do?
Well, you could use the C<TrailingSpaces> attribute
lib/Acme/EyeDrops.pm view on Meta::CPAN
And can further combine the above options, each combination
producing a different camel, for example:
perl camel.pl uri
produces a large, bearded camel with a pony-tail, glasses,
and a tie-dyed T-shirt. :)
F<camel.pl> also accepts an optional second argument, specifying
the character to fill the camel with (default C<#>).
For example:
perl camel.pl hv small camel filled with #
perl camel.pl hv "$" small camel filled with $
Why 12,032 camels? Combining the main options q, m, i, u, r, h, v
can produce 128 different camels. And there are 94 printable
characters available for the second argument, making a total
of 128 * 94 = 12,032 camels.
lib/Acme/EyeDrops.pm view on Meta::CPAN
If Regex is positive, embed the program in a regex and:
1: add a leading "use re 'eval';" for Perl 5.18+ only
2: do not add a leading "use re 'eval';"
3: add a leading "use re 'eval';"
Do not set this flag when converting complex programs.
Compact Boolean. If set, use compact sightly encoding.
Print Boolean. If set, use a print statement instead
of the default eval statement. Set this flag
when converting text files (not programs).
Binary Boolean. Set if encoding a binary file.
Text Boolean. Set if pouring unsightly text.
TextFiller Filler string used with Text attribute.
For example, TextFiller => '#'.
Gap The number of lines between successive shapes.
lib/Acme/EyeDrops.pm view on Meta::CPAN
Width Ignored for .eye file shapes. For built-in shapes,
interpreted appropriately for the shape, typically the
shape width in characters. If no shape is specified,
a rectangular block of Width characters is generated.
EyeDir Normally .eye files are got from the EyeDrops
directory underneath where EyeDrops.pm is located.
You can override that by specifying a directory
containing the .eye shape files.
InformHandler By default, sightly prints status of what it is
doing to STDERR; you can override this by providing
a subroutine reference taking a single inform string
argument. To shut it up, set to sub {}.
TrapEvalDie Boolean.
Add closing 'die $@ if $@' to generated program.
When an eval code block calls the die function,
the program does not die; instead the die string
is returned to eval in $@. Using this flag allows
you to convert programs that call die.
( run in 0.858 second using v1.01-cache-2.11-cpan-0a6323c29d9 )