This question can be understood at two different levels:
- Are those anonymous stuffs necessary in theory, in order to form a complete language? That’s a big question, and can well start a thread of interesting discussion here. However you might love to have them any way, for flexibility, performance...
- As we got those things in Perl already, does one really need to use them? Yes, and some times you are forced to use them. Here is one example where you are forced to use anonymous sub:
You can do this in Tk:
$mw->Button(command => \&func1)->pack;
but if func1 is a method of a class, you will not be able to say
$mw->Button(command => \&$self->func1)->pack;
and you have to say:
$mw->Button(command => sub {\&$self->func1})->pack;