Perl 5.8 doesn't have the fancy v5.20 Copy-on-Write ("COW") feature that ikegami mentioned (so the scalar of the copied version doesn't point to the same string buffer), but it does pass the subroutine arguments by reference (so the scalar is the same outside and inside of f($x) ). However, as soon as you make a copy of a string passed by reference, you no longer are using that reference, but a copy of the string -- hence, without COW, the memory goes up when you make the copy , but not when you called the sub . If, like ikegami, you stick to always using the $_[0] rather than creating a copy, it would not double your memory even in tinyperl.
Oh, Okay! I think, I understand it now. Thank you for explaining it at my level. Lol
In reply to Re^5: Passing argument by reference (for a scalar)
by harangzsolt33
in thread Passing argument by reference (for a scalar)
by jmClifford
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |