Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

f00li5h's scratchpad

by 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 data

The 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 Decoding

The 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

  • split'',B204316D8C2A4516DE which splits those B204316D8C2A4516DE into a list of single characters. ('B','2','0','4','3','1','6','D','8','C','2','A','4','5','1','6','D','E')
  • map hex LIST which turns each of the list elements from hex (base 15) to decimal (base 10) numbers, so it becomes (11,2,0,4,3,1,6,13,8,12,2,10,4,5,1,6,13,14)

The Reordering

so, 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

('better','to','ask','and','appear','f00li5h', 'for','a','moment','than','to','pretend','and','remain', 'f00li5h','for','a','lifetime')

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-1337ing

Then 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 out

Finally, 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

@_=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;

Hrm, there turned out to be more to it than I thought!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found