in reply to Re^2: Is it possible to sort using a coderef, without first storing the coderef in a scalar
in thread Is it possible to sort using a coderef, without first storing the coderef in a scalar
Because you have a choice according to the docs for sort. You can use a block, a subname, or (from the docs): "SUBNAME may be a scalar variable name (unsubscripted), in which case the value provides the name of (or a reference to) the actual subroutine to use." There is nothing in the docs that says you can use a subroutine call to return a sub reference. You can use a block, a subname, or a scalar variable containing the name of a sub or a reference to a sub. Nothing else. And your sub named in 'subname' must return an integer (-1, 0 or 1, for example). Likewise, the sub referred to in $subname must return an integer.
Dave
|
|---|