in reply to Re: Using Shift with Parameters in a subroutine
in thread Using Shift with Parameters in a subroutine
my ($one, $two) = _@;
works once, but ignores the side effect of shift (removing the arguments from the @_ array).As Marshall says, using a reference to an array would be the best way to deal with a lot of parameters, but if you wanted to, say, process two at a time, you could do
(you'll get an uninitialized value warning if you supply an odd number of parameters)while (my ($one,$two) = splice @_, 0, 2) { #do something }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Using Shift with Parameters in a subroutine
by perlron (Pilgrim) on Oct 25, 2014 at 17:59 UTC |