If you are saying you are passing a huge list (more than 3) of position dependent parameters to a sub then you are buying yourself trouble right from the get go. Instead load up a hash with the parameters as you discover them then pass the hash into the sub. That gives you the equivalent of named parameters. Consider:
use 5.010; ... my %params; my @parts = split '.', $mystring; $params{cheese} = $parts[0]; $params{country} = $parts[1]; $params{state} = $parts[2]; $params{town} = $parts[3]; doSumpton(%params); ... sub doSumpton { my %params = @_; $params{cheese} //= '-- bad cheese --'; # Provide cheesy default print "Cheese: $params{cheese}\n"; }
Using a hash slice the assignments to the hash can be done as:
@params{qw(cheese country state town)} = @parts;
In reply to Re^2: Are there corner cases I am missing
by GrandFather
in thread Are there corner cases I am missing
by monk2b
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |