Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Perl Idioms Explained - ${\$obj->method} and @{[sort @list]}

by ambrus (Abbot)
on Oct 20, 2014 at 10:47 UTC ( #1104410=note: print w/replies, xml ) Need Help??


in reply to Perl Idioms Explained - ${\$obj->method} and @{[sort @list]}

I've just seen a variant of this operator, the twin baby cart, "@{[...]}[...]" come up in golf. The original context is the golf task http://golf.shinh.org/p.rb?hello+hello+world where it's used by the winner perl entries by tails and tybalt89.

This combines list slice indexing with interpolation of the baby cart operator, and is particularly useful because the array interpolation makes sure spaces (the default value of $") are added between the items. An example is:

"@{[zero,one,two,three,four,five]}[3,1,4,1,5]"
has the result "three one four one five".

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1104410]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2017-12-17 20:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (466 votes). Check out past polls.

    Notices?