Beefy Boxes and Bandwidth Generously Provided by pair Networks chromatic writing perl on a camel
Keep It Simple, Stupid
 
PerlMonks  

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

by chromatic (Archbishop)
on Apr 03, 2000 at 21:53 UTC ( [id://6766]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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

Prepending a variable with a backslash (\) creates a reference:
my $scalar = "this is a scalar"; my @array = qw( this is my array ); my %hash = ( 'this' => 'my', 'hash' => 'mine',); print_all(\$scalar, \@array, \%hash); sub print_all { my $scalar_ref = shift; my $arr_ref = shift; my $hash_ref = shift; print "Scalar: ", $$scalar_ref, "\n"; print "Array: ", join ' ', @$arr_ref, "\n"; print "Hash: ", each %$hash_ref, "\n"; }
See perlman:perlref for the juicy details.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://6766]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.