Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Answer: Is it possible to do pass by reference in Perl

by btrott (Parson)
on Apr 04, 2000 at 03:12 UTC ( #6777=categorized answer: print w/replies, xml ) Need Help??

Q&A > subroutines > Is it possible to do pass by reference in Perl? - Answer contributed by btrott

... And, as would follow from chromatic's answer, if you modify the references within a subroutine, you'll also modify the values those references point to, outside the subroutine.
my $str = "foo"; print $str, "\n"; change(\$str); print $str, "\n"; sub change { my $ref = shift; $$ref = "bar"; }

Log In?

What's my password?
Create A New User
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2017-07-24 07:34 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (348 votes). Check out past polls.