This code uses a similar technique to that used
by the CPAN
Acme::EyeDrops
module. To illustrate, running this program:
use Acme::EyeDrops qw(sightly);
print sightly({ Regex => 1,
Print => 1,
Compact => 1,
SourceString => "allen\n" });
produces:
''=~('('.'?'.'{'.('['^'+').('['^')').('`'|')').('`'|'.').('['^'/').'"'
+.('`'|'!').('`'|',').('`'|',').('`'|'%').('`'|'.').('!'^'+').'"'.'}'.
+')')
which, when run through Deparse, produces:
'' =~ /(?{print"allen\n"})/;
For more fun, Acme::EyeDrops allows you to pour the generated
code into various shapes. For example, running:
use Acme::EyeDrops qw(sightly);
print sightly({ Shape => 'rose',
Regex => 1,
Print => 1,
Indent => 1,
SourceString => "allen\n" });
produces:
''=~('('.'?'
.'{'.('['^"\+").(
'['^')' ).+(
"\`"| (')')).( "\`"|
'.'). ('['^ '/').
"\"".( '`'| '!'). ("\`"|
','). ('`'| ',').( ('`')|
'%'). ('`'| '.').( '!'^'+'
).'"'.'}'. ')'); $:='.'^'~';$~=('@')|
'(';$^=')'^'[';$/ ='`'|('.');$,= '('
^'}';$\='`'|'!';$: =')'^'}';$~ ='*'
|('`');$^= '+'^'_'; $/='&' |'@'
;$,='['&'~' ;$\="\,"^ '|';$:=('.')^
'~';$~="\@"| '(';$^=')'^'[';$/='`'|'.';$,=
'('^'}';$\= '`'|'!';$:=')'^"\}"; ($~)=
'*'|'`';$^ ='+'^'_';$/=('&')| '@';$,
='['&'~'; $\= ','^'|';$: ='.'^'~'
;$~='@'|'(' ;$^= ')' ^('[');$/=
'`'|'.';$,='('^'}';$\= '`'|'!';$:=
')'^'}';$~='*'|'`';$^='+'^'_';$/="\&"|
'@';$,='['&'~';$\= ',' ^((
'|'));$:=('.')^
'~';$~= '@'
|((
'('
));
$^=
( ')')^'['; $/=
(( '`'))|'.'; $,=
"\("^ '}';$\='`' |((
'!')); $:=(')')^ '}'
;($~) ="\*"| '`'
;($^) =(( '+'
))^'_' ;($/)= '&'|'@';$,=
'['&'~';$\= ','^'|';$:=('.')^
'~';$~='@'| '(';$^=')'^ '[';$/=('`')|
'.';$,='('^ "\}";$\= ('`')| '!';$:="\)"^
'}';$~='*'| ('`');$^= '+'^'_'; $/='&'|'@'
;$,=('[')& ('~');$\= ','^"\|"; $:=('.')^
('~');$~= '@'|'(';$^ =')'^'[';$/ =('`')|
'.';$,= '('^'}';$\ ='`'|'!';$: ="\)"^
'}';$~ ='*'|'`'; $^='+'^'_'; ($/)
='&'| '@';$,= '[' &'~';$\= ','
^'|' ;($:) =(( '.'))^'~' ;(
$~) ='@' |(( "\("));
$^ =(( ')'
))^(( '['
)) ;$/
=((
'`'
));
|