Take off strict temporarily while you pipe it in the variable based subroutine calls.
{ no strict 'refs';
*{$ProdMod . "::Init"}->(\%Subroutines,$Debug);
}
$ProdMod is variable where subroutine call is call {$ProdMod."::Init"}. %Subroutines and $Debug are the input variables to the provided subroutine.
Also, can put it into hash or array which points to the subroutine calls as so:
my %Subs = (
"test1" => \&test1,
"test2" => \&test2,
"test3" => \&test3,
"test4" => \&test4,
);
And calls it:
$Subs{"test1"}($var1,$var2);
Considering you have test1-4 subroutine defined:
sub test1($$) {...}
9/12/2008
Perl Tip: Call variable based subroutines
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment