in reply to Re^2: How to call a sub reff from a hash
in thread How to call a sub ref from a hash
Taking your code and then switching the last line like he said makes it work perfectly.
#!/usr/bin/perl use strict; use warnings; sub Procedure_Name_1 { my($Parm) = shift; print($Parm); } my %Procedures; $Procedures{'ProcName1'} = \&Procedure_Name_1; my $Procedure = 'ProcName1'; my $Parameter = 'Some Value'; $Procedures{$Procedure}->($Parameter);
I don't understand why you ignored his advice but i would recommend trying it as written in the future.
BTW you could read the last line as "get the value of $Procedures{$Procedure} and then run it as a coderef ->( passing it $Parameter)"
|
|---|