![]() |
|
Perl-Sensitive Sunglasses | |
PerlMonks |
Re: providing a callback routine to sortby Anonymous Monk |
on Jan 21, 2014 at 23:01 UTC ( #1071541=note: print w/replies, xml ) | Need Help?? |
In Perl, "a reference" can be a reference to anything, including a subroutine (ref($whatever) eq 'CODE' ...) So, you certainly could provide sort with a subroutine that checks if $whatever refers to a subroutine, and if so, calls it ... otherwise taking some default action. . .
Notice how the sort routine, within your code, has only one clear subroutine to call. That subroutine, however, is faced with a decision.
In Section
Seekers of Perl Wisdom
|
|