Snippet Name: Call subroutine and pass variable by value
Description: Call a subroutine and pass a variable by value.
Comment: (none)
Language: PERL
Highlight Mode: PERL
Last Modified: March 06th, 2009
|
$value = "foo";
$newvalue = add_bar($value);
PRINT "$value becomes $newvalue";
SUB add_bar {
MY ($copy) = @_;
$copy .= "bar";
RETURN $copy;
}
# foo becomes foobar
# the special @_ array will always contain aliases to the
# variables that are passed in, so it really isn't possible
# to pass by value. |