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...
In reply to Re: Why use references?
by pileofrogs
in thread Why use references?
by w3b
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |