Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
f00li5h's scratchpadby f00li5h (Chaplain) |
on Jul 11, 2006 at 12:08 UTC ( [id://560414]=scratchpad: print w/replies, xml ) | Need Help?? |
Here's How my signature breaks down@_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;Note: Obviously perl golf is a game, in stark contrast to Best Practices. there's not a lot to it... It's a couple bits: The dataThe first @_=qw; ... ; just assigns a list of words (quotelike) into @_. (it's trixy because it uses ; as the delimiter) @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime; The DecodingThe second is a list slice (llama book), inside a regex replace. So, the stuff I just stuck into @_. slices take the form @...[ LIST ] (array slice) or @...{ LIST } (hash slice) The LIST however, is map hex,split'',B204316D8C2A4516DE, being
The Reorderingso, we have the list slice @_[11,2,0,4,3,1,6,13,8,12,2,10,4,5,1,6,13,14] which just pulls the words out of @_ in a different order... twelth first, then the third, then the first (arrays start at 0 afterall) this gives you the list
so, that list of words is interpolated into a regex that also uses ;'s as it's delimiters. This simply replaces the empty string with that list, and operates on $_ by default. It's the same as $_ = join ($", @_[ LIST ]), (when a list is interpolated into a string, it's elements are seperated with whatever's in $" from perlvar) The De-1337ingThen there's y/05/os/ which just replaces 0 with o and 5 with s (to de-1337 my nick). y/// is a shortcut for perlfunc's tr. Spitting it outFinally, we have a &print, printdefaults to printing $_, which is where all the action has been thus far. The & is a bitwise and, which serves no real purpose, it could have easily been a ;. Here it is, line broken at statements, with sensible delimiters
Hrm, there turned out to be more to it than I thought! |
|