in reply to Can't Reference a Sub by Variable when using Strict

Oops. Should have read the code a little more closely...

keys returns list of keys to the hash. your code is in the value of the hash

In light of tachyon's comment, here's what I *would have* done

my %lists = ( 'coderef_name1' => \&coderef1, 'coderef_name2' => \&coderef2 ); while (my($key, $code) = each %lists) { print "executing $key: "; $code->(); }

Replies are listed 'Best First'.
Re^2: Can't Reference a Sub by Variable when using Strict
by tachyon (Chancellor) on Oct 04, 2004 at 02:11 UTC

    Actually that is completely wrong. The keys are called test1 and test2. The subs are called test1 and test2. The sample code runs exactly as expected without strict. The problem is the use of symbolic references, which the sample code uses, but strict disallows. Your code would not run with or without strict.