in reply to my first (good) japh.
# # assign some chars to $_ # $_=q.$wHFGnABGUREcREYuNPXRE NAQyNEEL="larry".; # # do a regexp in a regexp # s!^\$(.+)=(.)(\S+)(\2)$!($foo=($foo=$1))=~s,((?:n|c|u|y).), $1,g!ex; # # simplified: # $foo = 'wHFG nABGURE cREY uNPXRE NAQ yNEEL'; # $3 = 'larry'; # # # split up "larry" into @x # @x = qw(l a r r y); # @x=split("",$3,-@-); # # map the values 4,17,-9,-4 and -5 # map{ $x[$y]=chr(($x[$y]=ord($x[$y]))+=$_); ++$y }qw(4 17 -9 -4 -5); # # this can be simplified to: # # $y=0; # for $a((4,17,-9,-4,-5)){ # $x[$y] = chr(ord($x[$y])+$a); # $y++; # } # # which can be further simplified to: # # $x[0] = chr(ord($x[0]) + 4); # $x[1] = chr(ord($x[2]) + 17); # $x[2] = chr(ord($x[3]) - 9); # $x[3] = chr(ord($x[4]) - 4); # $x[4] = chr(ord($x[5]) - 5); # # # assign the array in @x to $print # $print=join("",@x); # # $print now holds the string 'print' # (which was tranformed from 'larry' by the map) # # # do a tranliteration on $foo to change it to # "Just Another Perl Hacker and Larry" # $foo=~y.A-Za-z.n-za-mN-ZA-M.; # # using capture variables from the first regex, transform $japh to # "Just Another Perl Hacker and Larry.\n"; # $japh="$+$foo.\\n$2;"; # # eval the statement # eval"$print $japh";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: my first (good) japh.
by lshatzer (Friar) on Jun 08, 2001 at 01:25 UTC |