in reply to why use a coderef?

Nobody else has mentioned this, so I will

Private subroutines

In Pascal (sorry!) you can declare a sub within another sub. In Perl you can't. But you can define & use private subrefs:

sub my_realy_complicated_thing { my $easy_thing = sub { ... }; my $easier_thing = sub { ... }; ... my $x = $easy_thing->( @lots_of_complicated_stuff ); #etc }

Footnote
As I was typing this, I ended a sentence with ";"
Am I doing too much Perl?