- or download this
my @array = ( 1, 2, 3 );
for my $elem ( @array ){
say $elem;
}
- or download this
my $aref = \@array;
- or download this
ARRAY(0x9bfa8c8)
- or download this
for my $elem ( @{ $aref } ){
say $elem;
}
- or download this
my $x = $array[0];
- or download this
my $y = $aref->[1];
- or download this
$array[1] = "assigning to array element 2";
- or download this
$aref->[1] = "assigning to array element 2";
- or download this
my %hash = ( a => 1, b => 2, c => 3 );
...
say "key: $key, value: $value";
}
- or download this
my $href = \%hash;
- or download this
while ( my ( $key, $value ) = each %{ $href } ){
say "key: $key, value: $value";
}
- or download this
my $x = $hash{ a };
- or download this
my $y = $href->{ a };
- or download this
$hash{ a } = "assigning to hash key a";
- or download this
$href->{ a } = "assigning to hash key a";
- or download this
my @b = ( 1, 2, 3 );
my $aref = \@b;
...
for my $elem ( @b ){
say $elem;
}
- or download this
99
2
3
- or download this
$b[0] = 99;
$aref->[0] = 99;
- or download this
my @a = ( 1, 2, 3 );
my %h = ( a => 1, b => 2, c => 3 );
...
# assign a value to a single hash key through its ref
$h->{ a } = 1;