Wagner, David --- Senior Programmer Analyst --- WGO wrote:
Mind is blank or I have looked at a number of books, but I am just not
getting ir right.  Depending on the data provided, I want to invoke
proc_step1, proc_step3, etc. Each will have two params passed ($Myloc,
$MyTime). Dont want to hard code into table, but generate something like:

my $MySub = sprintf "proc_step%s", $MySubNbr;
execute the sub.
Have tried:
&$MySub($MyLoc, $MyTime); # and
&$MySub->($MyLoc, $MyTime)

Always get the following error:
Can't use string ("proc_step1") as a subroutine ref while "strict refs"
in use at /d/src/pl532.pl line 520, <MYFILEIN> line 2.

You are trying to use the symbol table as a hash when you should just use a 
hash:

perldoc -q "How can I use a variable as a variable name"


You want something like:

my %subs = ( 1 => \&proc_step1, 2 => \&proc_step2, ... );


$subs{ $MySubNbr }( $MyLoc, $MyTime ) if exists $subs{ $MySubNbr };



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to