in reply to Re: Re: Explicitly check for argument presence...
in thread Default subroutine parameters
repeatedly, perhaps the following would be useful :my $argN="default"; $argN=shift if @_;
This doesn't check that a user's supplied too many parameters, but that shouldn't be too hard to add in.&foo (1,2,3); sub foo { my @defaults= qw (foo bar baz quux quuz boo); for (1.. @_) {shift @defaults}; @_= (@_, @defaults); ($a1, $a2, $a3, $a4, $a5, $a6) = @_; print join "\n",$a1, $a2, $a3, $a4, $a5, $a6; }
|
|---|