Ronald J Kimball wrote:
> ''=~("(?{".('}_).} "*}_} }./}(}_ }}_, (}_+}_,*"'&
> ~'/-  +   *,+ <  + :- /:-   << :-  @'|
> '  ``   @     `` `   @  ` `  `   ')."})");
>
> Inspired by Abigail and Japhy's recent postings.
>
> Ronald

Ronald, that was very impressive! Using your trick
and ideas from Jas' delightful Acme::Smirch CPAN
module, I have come up with two program generators:

ob2.pl (Program generator based on Ronald's trick)
--------------------------------------------------
my %C;my $q;
# Default values.
$C{+chr} = "'" . chr() . "'" for 32..126;
# Sorry, can't handle these punctuation symbols.
$C{$_}="' '" for ('"',"'",'$','@','\\');
$C{"\n"} = q^'\\\\'.('`'|'.')^;
$C{'p'}  = q#(']'^'-')#;
# 'a' to 'o'
$C{chr($_+64)}=q^('`'|^.($q=$_==39?'"':"'").chr()."$q)" for 33..47;
# 'q'..'z'
$C{chr($_+80)}=q#((']'^'-')|#.($q=$_==39?'"':"'").chr()."$q)"
   for 33..42;
# 'A'..'Z'.
$C{+uc}=qq^($C{$_}&~\' ')^ for 'a'..'z';
print q^''=~('(?{'.^;
print qq^$C{p}.$C{r}.$C{i}.$C{n}.$C{t}.'"'^;
print map{'.'.$C{$_}}map/./gs,<>;
print q^.'"'.'})')^;

ob3.pl (uses older `$_` trick to write to stderr)
-------------------------------------------------
my %C;my $q;
# Default values.
$C{+chr} = "'" . chr() . "'" for 32..126;
# Sorry, can't handle these punctuation symbols.
$C{$_}="' '" for ('"',"'",'`','&','<','>','|','^','$','@','\\');
$C{' '}  = q^$"^;
$C{"\n"} = q^'\\\\'.($;|'.')^;
$C{'p'}  = '$:';
# 'a' to 'o'
$C{chr($_+64)}='($;|'.($q=$_==39?'"':"'").chr()."$q)" for 33..47;
# 'q'..'z'
$C{chr($_+80)}='($:|'.($q=$_==39?'"':"'").chr()."$q)" for 33..42;
# 'A'..'Z'.
$C{+uc}=qq^($C{$_}&~\$")^ for 'a'..'z';
my $e = q^$".'-'.($;|'%').'"'^;
print q^$#='#';$;='`';$:=$;|$%;$_=^;
print qq^$C{p}.$C{e}.$C{r}.$C{l}.$e.$C{w}.$C{a}.$C{r}.$C{n}.'\\"'^;
print map{'.'.$C{$_}}map/./gs,<>;
print q^.'\\""';`$_`^;

Example usage:
  perl ob2.pl fred.txt >fred.pl
where fred.txt contains, say:
  Just another Perl hacker
will generate a Perl program, fred.pl, containing
no alphnumeric characters. fred.pl can be manually
shaped into various animals or other things.

Andrew.

Reply via email to