in reply to Re^2: Build Sort dynamically
in thread Build Sort dynamically
The prototype is explained in the documentation to sort. If you provide the prototype, then the arguments are passed in @_. If you don't, then they are passed in $a and $b. Passing in $a and $b is marginally more efficient, but the problem comes when you create a sort routine in one package and call it in another. The package in which $a and $b are set is the one you call the sort routine in, and not the one you created the subs in. Which can become tricky. With the prototype, those cross-package problems go away.
This is potentially important in this case because depending on your overall code organization you may want to have each field know how to sort its own datatype. (Add a date-time field which could be in another language and it will quickly become apparent why you might want a more sophisticated organization.) Which would result in sort routines being spread out across packages.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Build Sort dynamically
by AnomalousMonk (Archbishop) on Aug 24, 2008 at 07:33 UTC | |
by tilly (Archbishop) on Aug 24, 2008 at 07:47 UTC |