Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: perl string pass by valueby ikegami (Patriarch) |
on Apr 02, 2018 at 16:55 UTC ( [id://1212184]=note: print w/replies, xml ) | Need Help?? |
Perl always passes by reference (not by value), so calling a sub doesn't copy the arguments. However, the standard practice is to copy the arguments into local variables (e.g. my ($x, $y) = @_;), effectively getting copy-by-value semantics. Since 5.20, Perl uses a copy-on-write mechanism that avoids actually copying the string until required (by the string being modified), so that copy is cheap.
So,
In Section
Seekers of Perl Wisdom
|
|