#!/usr/bin/perl use strict; use warnings; my @a1 = qq/one two three four five/; my @a2 = qq/six seven eight nine ten/; my %hash; $hash{key_1} = \@a1; $hash{key_2} = \@a2; braces(\%hash); no_braces(\%hash); sub braces { my $hash_ref = shift; foreach my $key (keys %$hash_ref) { foreach my $value (@{$hash_ref->{$key}}) { #Curly braces print "Key: $key, Value: $value\n"; } } } sub no_braces { my $hash_ref = shift; foreach my $key (keys %$hash_ref) { foreach my $value (@$hash_ref->{$key}) { #No curly braces print "Key: $key, Value: $value\n"; } } }
In reply to Dereferencing of an arrayref within a hashref by zecat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |