Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Shift versus Sanity

by rinceWind (Monsignor)
on Apr 24, 2002 at 10:05 UTC ( [id://161556]=note: print w/replies, xml ) Need Help??


in reply to Shift versus Sanity

These days, I tend to use @_ exclusively. However, there's one circumstance when shift wins: optional arguments. How about the classic get-and-set method for an accessor method of a scalar data item:
sub foo { my $self = shift; @_ ? ($self->{foo} = shift) : $self->{foo}; }
However, as a general rule for optional arguments, I tend to use a named parameter scheme, passing in key=>value pairs cast internally to a hash.
&blah( foo=>2, bar=>'Fred');

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2024-03-28 18:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found