programming-examples/perl/Datatype/Direct Reference Techniques.pl
2019-11-15 12:59:38 +01:00

20 lines
557 B
Perl

#!/usr/local/bin/perl
$var = "AnyThing";
#Save address of scalar variable $var
$ref = \$var;
#Dereference $ref printing value of $var
print "Value = $$ref\n";
#Save address of scalar $ref, itself a reference
$doubleRef = \$ref;
#Dereference $doubleRef, then dereference contained reference
print "Double Reference Value = $$$doubleRef\n";
#Save address of scalar $doubleRef, itself a reference
$tripleRef = \$doubleRef;
#Dereference $tripleRef, then dereference contained references
print "Triple Reference Value = $$$$tripleRef\n";