in reply to Using a 'getopt' in module code

Yet another method is to use a callback. For example,

mysort(\@list, 'age', 'asc', 'name', 'asc');

can be replaced with

mysort(sub { $_[0]{age} <=> $_[1]{age} || $_[0]{name} cmp $_[1]{name} }, @list);

With the right prototype (mysort (&@) { ... }), the above can also be written as

mysort { $_[0]{age} <=> $_[1]{age} || $_[0]{name} cmp $_[1]{name} } @list;

I haven't read it, but I believe the book "Higher Order Perl" has a lot on this subject.