zecat has asked for the wisdom of the Perl Monks concerning the following question:
#!/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"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dereferencing of an arrayref within a hashref
by LanX (Saint) on Feb 17, 2015 at 08:51 UTC | |
|
Re: Dereferencing of an arrayref within a hashref
by Not_a_Number (Prior) on Feb 17, 2015 at 09:20 UTC |