Quick Search:
 
 Perl Code: Call subroutine and pass variable by value Jump to:  
Category: >> Perl Code >> Call subroutine and pass variable by value  

<< lastnext >>

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.


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org