in reply to Re: [Study]: Searching for square roots
in thread [Study]: Searching for square roots

If I needed to pull more than one value off the front of @_ and leave the rest I'd possibly use splice:

my ($arg1, $arg2) = splice 0, 2, @_;

but more likely I'd pull the tail elements out into an array:

my ($arg1, $arg2, @tail) = @_;

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^3: [Study]: Searching for square roots
by blazar (Canon) on Nov 15, 2006 at 09:37 UTC

    Well, I do use splice occasionally, but not for argument passing. I'd either do

    my $arg1=shift; my $arg2=shift;

    or as in your second alternative, the point still being that multiple shift's on one line can be confusing albeit potentially correct, and IMHO clearly neither particularly concise nor expressive in terms of readability. Anyway what I choose depends on the emphasis I want to put on each argument. Fortunately in a not (any more) so remote future we will avoid all these parameter passing acrobatics...