Beefy Boxes and Bandwidth Generously Provided by pair Networks
Joe Problems? Is your data what you think it is?  Re: pass by
value vs reference and return by value  by Athanasius (Prior) on
Oct 27, 2013 at 14:57 UTC ( #1059911=note: print w/ replies,
xml ) Need Help??  in reply to pass by value vs reference and
return by value  In C and C++, the default mechanism for passing
arguments to a function is pass-by-value. To get pass-by-
reference, you need to (in effect) override the default by
explicitly either (1) passing a pointer (simulated pass-by-
reference) or (2) declaring the function parameter to be a
reference (C++ only).  In Perl, it’s the other way around. The
default mechanism for passing arguments to a subroutine is pass-
by-reference. For example, if you call:  foo($x, $y, $z);  then
within the body of sub foo the special array variable @_
contains references to the three arguments. In Perl terminology,
$_[0] is an alias for $x, $_[1] is an alias for $y, and $_[2] is
an alias for $z. This is strictly