http://www.perlmonks.org?node_id=156538


in reply to Accessing Subroutine Arguments

I actually prefer to use the "named parameter" method. Not only does it lead to more readable code, but you can do neat things with defaults this way.
use strict; use Data::Dumper; sub foo { my %opt = ( text => 'Default Text' , style => 'Default Style' , bar => 'belch' ); %opt = ( %opt, @_ ); print Dumper \%opt; } foo(); # Options stay as specified above. foo( bar => 'yuk' ); # $opt{text} and $opt{style} stay the same, # $opt{bar} becomes 'yuk' instead of 'belch'.
I find this really handy for functions that can have a lot of obscure parameters that you only want to change once in a blue moon.