You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
481 B
Perl

5 years ago
#To set up a reference, you use a backslash (\) character before the name of what you're referring to.
#$reference = \$referred_to;
#The reference is a scalar variable.
#To access the value of the data referred to:
#$new_var = ${ $reference };
#You can also use a shorthand syntax like the following:
#$new_var = $$reference;
#!/usr/bin/perl -w
# Reference to a scalar variable.
$var = "Hello";
$reference = \$var;
print "Scalar reference = $$reference\n\n";