http://qs1969.pair.com?node_id=225696

c has asked for the wisdom of the Perl Monks concerning the following question:

I'm very new to HoHoL or HoH for that matter. Basically I have a hash of hashes. One of the values of a nested hash is an array of subroutine references that I would like to execute.

#!/usr/bin/perl -w use strict; my %HoL = ( one => [ (\&hello, \&goodbye,) ], two => [ (\&hello,) ], ); for my $key(%HoL) { for my $i(@{$HoL{$key}}) { print "$key -> &{$HoL{$key}->{$i}}\n"; } } sub hello { print "hello"; } sub goodbye { print "bye"; }

I've messed around with replacing the sub routine references with just text values and looping over them for printing and things go alright. So, I'm suspecting that there is a problem in the manner that I am calling the subroutine. I've messed around with different manners of calling the routines as well as just calling the first with &{$HoL{$key}[0]}

for my $key(%HoL) { &{$HoL{$key}[0]}; }

which seems to be successful but still produces an error complaining about a "" string being used as a subroutine. I'm just not sure where that is coming from since both keys have arrays with at least one element.

I appreciate your advice. Thanks -c