http://qs321.pair.com?node_id=161556


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');