On 02/12/2007 03:26 PM, Ana Saiz García wrote:
Hello

First of all, I apologize if this is not the right list to ask my question, but as I am a perl beginner, I think it is the most suitable list for me :o)

So here goes my question:

I have a main program which will call a subroutine, say "S", belonging to another module. The question is that there could be several modules that contain a subroutine also named "S", which basically will return equivalent values to the main program.

My problem is that I don't want to harcode the name of those modules (for example using an "if"), because I don't know a priori how many there will be or which will be needed to call at any moment. The idea is that there will be a file in which the main program could read which module is necessary in each moment, and so call it.

So the question is: Is there any way to call a subroutine without explicitly writing his name?

Thanks in advance, and if I haven't been able to explain it well, please ask
me :o)

Regards

Ana



It sounds like the module names are variable, but the subroutine name is constant. If so, you can write the subroutine to behave like a method and call it thusly:

$modulename->subname();

Of course, you would get the correct module name into $modulename first.


HTH




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


Reply via email to