in reply to "No strict refs" will be the death of me
To answer your questions in reverse order....
Second, why is this a considered a subroutine ref in the first place? I thought that a subroutine ref was this: \&Subref, which would return a memory address.
That's a "hard" reference. A "soft" reference is something of the form
$foo = 'bar'; $$foo = 'baz'; print $bar; #prints 'baz'
To answer your first question, AFAIK, you can't. The whole point of use strict 'refs' is to prevent you from using soft references. Furthermore, you can't use hard references as hash keys (they get converted to strings, and reference count information is lost). Perhaps this would work instead?
#!/usr/bin/perl -w use strict; my %Foo = ('Routine' => { SUB => \&Routine, FLAG => 1 }, 'Option' => { SUB => \&Option, FLAG => 0 } ); foreach (keys %Foo) { $Foo{$_}{SUB}->() if $Foo{$_}{FLAG}; }
--
Ryan Koppenhaver, Aspiring Perl Hacker
"I ask for so little. Just fear me, love me, do as I say and I will be your slave."
|
|---|