Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^2: Why use references?

by chas (Priest)
on Dec 12, 2005 at 01:55 UTC ( #515929=note: print w/replies, xml ) Need Help??

in reply to Re: Why use references?
in thread Why use references?

In your "Without References" example, don't you need  return ++$arg;?
(and a semicolon after shift?)
Also, consider the following:
sub increment { ++$_[0]; } $num=0; increment($num); print $num,"\n";
which shows that args are passed "by reference" by default. Of course, it may not be good style to alter @_ in this way, but the point is that you don't need to pass a reference to alter the argument inside the sub.
(Updated to make less confusing.)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2016-10-27 10:29 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (358 votes). Check out past polls.