Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^5: Prototype like sort()?

by Laurent_R (Canon)
on Jan 28, 2018 at 00:09 UTC ( [id://1208003]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Prototype like sort()?
in thread Prototype like sort()?

While I fully agree with Marshall that prototypes should generally be avoided (that is, unless you really know what your doing and why), and with you that, similarly, $a and $b should also be avoided most of the time, I think that we shouldn't be too dogmatic about that and that it does make sense to use both prototypes and the $a and $b special variables if you're going to write your own sort subroutine.

BTW, the List::Util module documentation illustrates some cases where it makes perfect sense to use the $a and $b variables in a context that has nothing to do with sorting.

In the example that I gave in Re: Prototype like sort()?, I'm localizing $a and $b before using them to avoid (at least, I hope) any side effects with their use somewhere else.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-25 06:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found