Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Dropping the ampersand

by ikegami (Patriarch)
on Feb 09, 2007 at 21:42 UTC ( #599290=note: print w/replies, xml ) Need Help??


in reply to Dropping the ampersand

sort treats the first parameter specially if it looks like a function name. It uses the function by the specified name as the compare function during sorting. You can use a unary-+ to disambiguate.

@livesys = sort +Con::liveones;
is the same
@livesys = sort { $a cmp $b } Con::liveones;
with no lost efficiency.

It's no better and no worse than
@livesys = sort &Con::liveones;

Both are better than
@livesys = sort @{[Con::liveones]};

Replies are listed 'Best First'.
Re^2: Dropping the ampersand
by diotalevi (Canon) on Feb 10, 2007 at 00:45 UTC

    You don't lose any efficiency with sort { $a cmp $b }. It's special cased along with several other similar kinds of sorts.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://599290]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2022-01-27 06:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (70 votes). Check out past polls.

    Notices?