Keep It Simple, Stupid | |
PerlMonks |
Re: Mini Japhby domm (Chaplain) |
on Sep 06, 2002 at 07:28 UTC ( [id://195589]=note: print w/replies, xml ) | Need Help?? |
nice one!
SPOILER:
s iir ejkucsath alnroetph eri; Using i as a delimiter, you substitute nothing with the string "r ejkucsath alnroetph er" (BTW, this only works if you put a space between the s (or q, qq, etc) and the delimiter), thus putting the string in $_;
split$+ This splits the string in $_ on the value of $+ (Last Paren Match), which is undef. So we end up with the array @_ containing each letter of the string in $_ as an element. print$_[$-++]until($-++>$#_); This prints every other element of @_, starting with 0 (i.e. 0,2,4,6,8..). $- (default 0) is used as an array index, but it is incremented twice: One time in the until-test, and one time in the array-indexing itself. The printing stops when $- is greater then the number of elements in @_ ($#_) print$_[$---]until($---<1); Basically the same as the last line, only in the other direction. $- now points to the last element of @_. $- gets decremented twice, so now all odd numbers are printed (.. 7,5,3,1) until $- is smaller then 1. And that's it. One small comment on the last command: This works, too, and is shorter: print$_[$---]while($---); But in fact I like the symmetry more...
In Section
Obfuscated Code
|
|