c has asked for the wisdom of the Perl Monks concerning the following question:
#!/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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash of Hash of Listed subroutines
by ihb (Deacon) on Jan 10, 2003 at 01:27 UTC | |
|
Re: Hash of Hash of Listed subroutines
by djantzen (Priest) on Jan 10, 2003 at 00:44 UTC | |
|
Re: Hash of Hash of Listed subroutines
by Kanji (Parson) on Jan 10, 2003 at 00:39 UTC | |
|
Re: Hash of Hash of Listed subroutines
by jdporter (Paladin) on Jan 10, 2003 at 00:49 UTC | |
|
Re: Hash of Hash of Listed subroutines
by OM_Zen (Scribe) on Jan 10, 2003 at 18:53 UTC |