programming-examples/perl/Datatype/References, Pointers.pl

19 lines
617 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#Perl references are also called pointers.
#A pointer is a scalar variable that contains the address of another variable.
#To create a pointer, the backslash operator is used.
# Create variables
$age = 25;
@siblings = qw("A", "B", "C","D");
%home = ("owner" => "A",
"price" => "B",
"style" => "C",
);
# Create pointer
$pointer1 = \$age;
$pointer2 = \@siblings;
$pointer3 = \%home;
$pointer4 = [ qw(red yellow blue green) ]; # Create anonymous array
$pointer5 = { "A" => "a", "B" => "b", "C" => "c" };
# Create anonymous hash