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

Re: providing a callback routine to sort

by Anonymous Monk
on Jan 21, 2014 at 23:01 UTC ( #1071541=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2022-08-17 22:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?