This should work for you.
use strict;
use warnings;
my( %hash1, %hash2, %hash3 );
my @hash_refs = ( \%hash1, \%hash2, \%hash3 );
for my $hash_ref ( @hash_refs ){
for my $key ( keys %$hash_ref ){
my $value = $hash_ref->{$key};
}
}
It uses hash links instead of using symbolic links. It is very easy to get symbolic links incorrectly and can be difficult to debug.
Here is how you could use symbolic links, but I would advise you to do so.
use strict;
use warnings;
our( %hash1, %hash2, %hash3 );
my @hash_names = qw' hash1 hash2 hash3 ';
for my $hash_name ( @hash_names ){
print STDERR "WARNING: using symbolic references\n";
no strict 'refs';
for my $key ( keys %$hash_name ){
my $value = $hash_name->{$key};
use strict 'refs';
}
use strict 'refs';
}
source
share