http://www.perlmonks.org?node_id=1071541


in reply to providing a callback routine to sort

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.
  • Comment on Re: providing a callback routine to sort