in reply to Maintaining strict refs while Binding a set of variables to @_ or dying if they are not defined
Hey, you could even use a pseudohash so you can use the names instead of indices:sub someFunc { my @args = qw( client_number MM DD S ); # no commas here for (@args) { $_ = defined($_[0]) ? shift : die "$_ not defined"; } # hooray }
sub someFunc { my $args = [ { client_number => 1, MM => 2, DD => 3, S => 4, }, ]; for (keys %$args) { my $idx = $args->[0]{$_} - 1; if (defined $_[$idx]) { $args->{$_} = $_[$idx], next } die "$_ not defined"; } # hooray }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Maintaining strict refs while Binding a set of variables to @_ or dying if they are not defined
by Fastolfe (Vicar) on Nov 30, 2000 at 01:38 UTC |