search.cpan.org/dist/Acme-EyeDrops/lib/Acme/EyeDrops.pm
DESCRIPTION ^ Acme::EyeDrops converts a Perl program into an equivalent one, but without all those unsightly letters and numbers. In a Visual Programming breakthrough, EyeDrops allows you to pour the generated program into various shapes, such as UML diagrams, enabling you to instantly understand how the program works just by glancing at its new and improved visual representation. Unlike Acme::Bleach and Acme::Buffy, the generated program runs without requiring that Acme::EyeDrops be installed on the target system.
Just another Perl hacker Let's get more ambitious and create a big self-printing JAPH. In this case, we must resort to: print sightly( { Shape => 'japh', SourceString => $src, Regex => 0 } ); which runs the generated sightly program via eval instead. If you want to use Regex => 1 (to eliminate all alphanumerics), ensure the program to be converted is careful with its use of regular expressions and $_. To produce a JAPH that resembles the original Just another Perl hacker, aka Randal L Schwartz, try this: print sightly( { Shape => 'merlyn', SourceString => 'Just another Perl hacker,', Regex => 1, Print => 1 } );
tmp 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 Buffy looking in the mirror. pl cat bpl (should show Buffy's face) perl bpl (should show Buffy looking in the mirror) Drat.
A Somersaulting Camel Let's extend the Buffy example of the previous section to produce a camel-shaped program capable of somersaulting across the screen when run. pl: print sightly( { Regex => 1, Compact => 1, RemoveNewlines => 1, Indent => 1, BorderGapRight => 1, Shape => 'camel', SourceString => <<'END_SRC_STR' } ); pl, so long as you also add a blank line after this header line.
Twelve Thousand and Thirty Two Camels In a similar way to the somersaulting camel described above, we create a camel-shaped program capable of emitting twelve thousand and thirty two different camels when run. pl: print sightly( { Regex => 1, Compact => 1, RemoveNewlines => 1, BorderGap => 1, Shape => 'camel', SourceString => <<'END_SRC_STR' } ); pl uri produces a large, bearded camel with a pony-tail, glasses, and a tie-dyed T-shirt. pl also accepts an optional second argument, specifying the character to fill the camel with (default #). 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.
Naked Arm Wrestling The final auction at Y::E 2002 in Munich featured an epic athletic contest which you can remember with: use Acme::EyeDrops qw(sightly); my $s = sightly( { Regex => 1, Shape => 'naw', Indent => 1, SourceString => <<'NAKED_ARM_WRESTLING' } );
Baghdad Bob Running this program: print sightly( { Shape => 'baghdad', Regex => 1, Compact => 1, RemoveNewlines => 1, BorderGap => 1, BorderWidthLeft => 3, BorderWidthRight => 3, BorderWidthTop => 2, BorderWidthBottom => 8, SourceString => <<'FAMOUS_COMICAL_ALI_QUOTES' } );
net/ features programs to display the lyrics of the famous 99 bottles of beer song in over 700 different computer languages. Over the years, many different Perl solutions have been proposed. On December 25 1998, for instance, Damian Conway suggested using his Lingua::EN::Inflect module: use Lingua::EN::Inflect 'inflect';
Dueling Dingos During the TPR02 Perl Golf tournament, /anick composed a poem describing his experience, entitled Dueling Dingos. You can produce a program that emits his moving poem like this: print sightly( { Shape => 'yanick3', Regex => 1, Print => 1, SourceString => <<'END_DINGO' } );
To generate a shorter program summarising /anick's TPR02 anguish: print sightly( { Shape => 'yanick,eye,mosquito,coffee', Gap => 3, Regex => 1, Print => 1, SourceString => <<'END_SUFFERING' } ); My head is hurting, my right eye feels like it's going to pop like a mosquito drinking from an expresso addict with high blood pressure, I want to crawl somewhere damp and dark and quiet and I consider never to touch a keyboard again.
Error Handling The sightly function returns a properly shaped program string; So if you are calling sightly in an environment where it's unacceptable to die, be sure to wrap the sightly call in an eval block.
Function Reference ascii_to_sightly STRING Given an ascii string STRING, returns a sightly string. sightly_to_ascii STRING Given a sightly string STRING, returns an ascii string. regex_print_sightly STRING Given an ascii string STRING, returns a sightly-encoded Perl program with a print statement embedded in a regular expression. regex_eval_sightly STRING Given a Perl program in ascii string STRING, returns an equivalent sightly-encoded Perl program using an eval statement embedded in a regular expression. clean_print_sightly STRING Given an ascii string STRING, returns a sightly-encoded Perl program with a print statement executed via eval. clean_eval_sightly STRING Given a Perl program in ascii string STRING, returns an equivalent sightly-encoded Perl program using an eval statement executed via eval. regex_binmode_print_sightly STRING Given an ascii string STRING, returns a sightly-encoded Perl program with a binmode(STDOUT) and a print statement embedded in a regular expression. Note that STRING may contain any character in the range 0-255. This function is dodgy because regexs don't seem to like binary zeros; clean_binmode_print_sightly STRING Given an ascii string STRING, returns a sightly-encoded Perl program with a binmode(STDOUT) and a print statement executed via eval. Note that STRING may contain any character in the range 0-255. get_builtin_shapes Returns a list of the built-in shape names. get_eye_shapes Returns a list of the eye shapes in ascii-betical order. get_eye_keywords Returns a hash reference keyed by keyword, with the value being the list of shapes containing the keyword. find_eye_shapes KEYWORDLIST Returns a list of the eye shapes in ascii-betical order that contain all keywords in KEYWORDLIST. The keywords in KEYWORDLIST are implicitly AND'ed together. Additionally, you may use OR inside any KEYWORDLIST element. If this is unclear, see the examples in "Shape Properties" section below. eye SHAPENAME, returns a hash reference of the shape properties or undef if the shape has no properties. make_triangle WIDTH Returns a triangle shaped string of WIDTH characters. make_siertri WIDTH Returns a Sierpinski triangle shaped string containing 2**WIDTH lines. Returns a banner of STRING, using the Linux command /usr/games/banner -w WIDTH. border_shape SHAPESTRING GAP_LEFT GAP_RIGHT GAP_TOP GAP_BOTTOM WIDTH_LEFT WIDTH_RIGHT WIDTH_TOP WIDTH_BOTTOM Put a border around a shape. reduce_shape SHAPESTRING FACT Reduce the size of a shape by a factor of FACT. expand_shape SHAPESTRING FACT Expand the size of a shape by a factor of FACT. rotate_shape SHAPESTRING DEGREES RTYPE FLIP Rotate a shape clockwise thru 90, 180 or 270 degrees. RTYPE=0 big rotated shape, RTYPE=1 small rotated shape, RTYPE=2 squashed rotated shape. FLIP=1 to flip (reflect) shape in addition to rotating it. hjoin_shapes GAP SHAPESTRINGLIST Join the shapes specified by SHAPESTRINGLIST horizontally with GAP spaces between each shape. pour_text SHAPESTRING TEXTSTRING GAP FILLTEXT Given a shape string SHAPESTRING, a string TEXTSTRING, and a GAP between successive shapes, returns a properly shaped string. FILLTEXT (typically '#') is text to be used as a filler for any leftover part of the shape (if not set, don't fill in leftovers). pour_sightly SHAPESTRING PROGSTRING GAP RFILLVAR COMPACT IH Given a shape string SHAPESTRING, a sightly-encoded program string PROGSTRING, and a GAP between successive shapes, returns a properly shaped program string. RFILLVAR is either a reference to an array of filler variables or, alternatively, a string to fill the leftover of the last shape with. A filler variable is a valid Perl variable consisting of two characters: $ and a punctuation character.
If COMPACT is 1, use compact sightly encoding, if 0 use p...
|