in reply to Why use references?
With References
|
Without References
|
I don't think my sub that uses references is any better than the one that doesn't. It just shows two ways of doing the same thing.
Because you pass $num as a reference, the subrutine can change num. Then you can use the function's return for something else.
Update: chas! I've fixed the example to use ++$arg rather than $arg++.
AND! Woah. Baked my noodle with that one. So the only reason I've been convinced that subrutine args were passed as values was because I was using shift all the time!? Man... aye aye aye...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why use references?
by chas (Priest) on Dec 12, 2005 at 01:55 UTC |