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:
(Updated to make less confusing.)
(and a semicolon after shift?)
Also, consider the following:
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.sub increment { ++$_[0]; } $num=0; increment($num); print $num,"\n";
(Updated to make less confusing.)
|
---|
In Section
Seekers of Perl Wisdom