Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: [Study]: Searching for square roots

by GrandFather (Saint)
on Nov 14, 2006 at 17:41 UTC ( [id://584011]=note: print w/replies, xml ) Need Help??


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...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://584011]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-29 00:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found