I am having difficulties understanding how the referencing and dereferencing of hashes works in perl.
I have a hash of 3 levels defined as this:
%languages = (
'en', (
'it', ( 'pattern1', '...', 'pattern2', '...' )
'de', ( 'pattern1', '...', 'pattern2', '...' )
)
'it', (
'en', ( 'pattern1', '...', 'pattern2', '...' )
'de', ( 'pattern1', '...', 'pattern2', '...' )
)
'de', (
'en', ( 'pattern1', '...', 'pattern2', '...' )
'it', ( 'pattern1', '...', 'pattern2', '...' )
)
);
and want to iterate on the second level of one of the hashes of the first level like this:
my $current_language = 'de';
while ( ( my $language, my $patterns ) = each %{ $languages{ $current_language } } )
{
print $patterns->{'pattern1'};
}
but i get the following error
Can't use string ("en") as a HASH ref while "strict refs" in use
I would appreciate any help on this.