Instead of an array, you could change to a hash and use the
subroutine name as the key.  Then if the key is defined, you execute
otherwise bypass.

Wags ;)

-----Original Message-----
From: Zielfelder, Robert [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 24, 2002 10:44
To: '[EMAIL PROTECTED]'
Subject: Using a variable name to invoke a subroutine


I have a script that uses an array to determine weather or not a subroutine
needs to be run or not.  I want to be able do a foreach on the array and
invoke the subroutine using the control variable.  The names of the
subroutines are the same as the items inside the array.  This is what I have
so far:

.....
foreach $sub (@list_of_subs) {
        &{$sub};  ##-- this is the part I am stuck on.  This doesn't work
}
.....

I have a bunch of subroutines defined in the script, but they don't need to
be invoked unless the "@list_of_subs" contains the name of the sub.  I know
that I could stick a bunch of if statements in there and make this work, but
I am trying to be a little more efficient if I can.  Any insight would be
appreciated.

Best Regards,

Rz


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to