Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: reference to a subby sk (Curate) |
on Sep 11, 2005 at 07:34 UTC ( [id://491027]=note: print w/replies, xml ) | Need Help?? |
I think the question of when references to subs are used and anonymous subs are used is too broad. Here is a simple example of anonymous sub -
In the above block we passed an anonymous sub to sort. It is just easy (convenient) to write numeric sort that way than to define a sub that returns $a <=> $b An example of sub ref is signal handling
These examples are very simple. Others might contribute better examplese. Another thing i can think of is closures where you return a reference to a sub from inside another sub. -SK
In Section
Seekers of Perl Wisdom
|
|