http://www.perlmonks.org?node_id=1091091


in reply to Cant coerce

The line

foreach my $rt ( @{$first{$fr}{$tg}{$ab}}){

tells that $first{$fr}{$tg}{$ab} is a reference to an array.

In the line

my $val = $first{$fr}{$tg}{$ab}{$rt} ;

you use it as if it were a reference to a hash. That's what the problem is.

If you remove that line and change the one after to

print " print $fr, $tg, $ab, $rt;"

you will probably get what you want. (I cannot test as you have not provided runnable code nor data.)