There's more than one way to do things PerlMonks

### Re: my first (good) japh.

by iamcal (Friar)
 on Jun 07, 2001 at 12:27 UTC Need Help??

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
Not bad :o) Now you took all the fun out of it though! ;o)

Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://86493]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-06-15 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?

No recent polls found

Notices?
 • erzuuli ‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.