Front page | perl.fwp |
Postings from September 2001
Re: World's Largest JAPH
Thread Previous
|
Thread Next
From:
Andrew.Savige
Date:
September 12, 2001 19:12
Subject:
Re: World's Largest JAPH
Message ID:
C0D2F5944500D411AD8A00104B31930ED6CBA7@ir_nt_server2
Bart Lateur wrote:
> But how is the japh "generated" from this code? Are you saying there's a
> "banner" program that turns plain source into this kind of weird shit?
> Still with the original functionality as a perl script?
OK, I admit I am working on such a program.
I blame Japhy, who posted on 8-Aug-2001:
> Why not:
> 0=~"(?\173\LPRINT\E'J\LUST ANOTHER\E P\LERL\E H\LACKER\12'\175)";
and Ronald J Kimball who posted on 17-Aug-2001:
> ''=~("(?{".('}_).} "*}_} }./}(}_ }}_, (}_+}_,*"'&
> ~'/- + *,+ < + :- /:- << :- @'|
> ' `` @ `` ` @ ` ` ` ')."})");
To produce the JAPH, I used three programs:
1) Linux /usr/games/banner to generate the banner.
2) Program to convert a Perl program into another containing
no alphanumeric characters (see Filth module below).
3) Program to pour the program generated by step 2
into the banner generated in step 1.
The step 2 program uses a conversion module called Filth.
I have no CPAN experience, and am open to suggestion, but
this module might eventually become CPAN Convert::Filth (??).
package Filth;
require 5.005;
use strict;
use vars qw($VERSION @ISA @EXPORT_OK);
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(ascii_to_filth filth_to_ascii print_filth eval_filth);
$VERSION = '0.01';
my @C=map{"'".chr()."'"}0..255;
$C[9] = q#'\\\\'.('/'^'[')#;
$C[10] = q#'\\\\'.('`'|'.')#;
$C[32] = q#('{'^'[')#;
$C[34] = q#'\\\\'.'"'#;
$C[36] = q#'\\\\'.'$'#;
$C[39] = q#"'"#;
$C[64] = q#'\\\\'.'@'#;
$C[92] = q#'\\\\'.'\\\\'#;
$C[123] = q#'\\\\'.'{'#;
$C[125] = q#'\\\\'.'}'#;
# 'a'..'o'
my $q;
for (33..47) {
$C[$_+64] = q#('`'|#.($q=$_==39?'"':"'").chr()."$q)";
}
# 'p'..'z'
my $c=112;
for (43,42,41,40,47,46,45,44,35,34,33) {
$C[$c++] = q#('['^#.($q=$_==39?'"':"'").chr()."$q)";
}
# 'A'..'O'
for (33..47) {
$C[$_+32] = q#('`'^#.($q=$_==39?'"':"'").chr()."$q)";
}
# 'P'..'Z'
$c=80;
for (43,42,41,40,47,46,45,44,35,34,33) {
$C[$c++] = q#('{'^#.($q=$_==39?'"':"'").chr()."$q)";
}
# '0'..'9'
$c=48;
for (46,47,44,45,42,43,40,41,38,39) {
$C[$c++] = q#('^'^('`'|#.($q=$_==39?'"':"'").chr()."$q))";
}
$C[56] = q#(':'&'=')#;
$C[57] = q#(';'&'=')#;
sub ascii_to_filth {
join('.', map($C[ord], split("", $_[0])));
}
sub filth_to_ascii {
eval eval q#'"'.# . $_[0] . q#.'"'#;
}
sub print_filth {
q#''=~('('.'?'.'{'.# . ascii_to_filth('print') . q#.'"'.# .
&ascii_to_filth . q#.'"'.'}'.')')#;
}
sub eval_filth {
q#''=~('('.'?'.'{'.# . ascii_to_filth('eval') . q#.'"'.# .
&ascii_to_filth . q#.'"'.'}'.')')#;
}
sub clean_print_filth {
'print eval' . q#'"'.# . &ascii_to_filth . q#.'"'#;
}
sub clean_eval_filth {
'eval eval' . q#'"'.# . &ascii_to_filth . q#.'"'#;
}
1;
The JAPH was generated with the eval_filth() function.
Interestingly, I had to change:
$x =~ s/\S/#/g;
to
$x =~ tr/!-~/#/;
because the former caused the generated Perl program to
malfunction in strange ways. I guess because the whole
program is running inside a regex, there are some
limitations on what the source program can do.
I have found the clean_eval_filth() function above to be
much more robust; it can convert just about any working
program (at the cost of 8 alphabetic characters).
If you are interested in the program that pours the
generated program into the required shape, please
let me know.
Andrew.
Thread Previous
|
Thread Next