Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

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


in reply to Is it possible to do pass by reference in Perl?

... 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://6777]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2021-05-16 12:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (151 votes). Check out past polls.

    Notices?