in reply to reference to a sub
Here is a simple example of anonymous sub -
my @sorted = sort { $a <=> $b } @unsorted;
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.$SIG{INT} = \&catch_int;
-SK
|
|---|