in reply to Re: Explicitly check for argument presence...
in thread Default subroutine parameters
This would be analogous to default arguments in C++, for instance.sub lotsaArgs { my $arg1 = 'default'; $arg1 = shift if @_; my $arg2 = 'default'; $arg2 = shift if @_; my $arg3 = 'default'; $arg3 = shift if @_; my $arg4 = 'default'; $arg4 = shift if @_; ... }
If you want to have named arguments, and only pass some of them, then the hash of default values and
as suggested below is obviously better.my %args=(%defaults,@_);
But as asked, he seemed to have only one arg to default.
--
Mike
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (3) Explicitly check for argument presence... (boo)
by boo_radley (Parson) on Apr 22, 2002 at 23:14 UTC |