Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by ambrus (Abbot)
on Oct 20, 2014 at 10:47 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1104410]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-03-19 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found