Let’s say I’m doing this in my main script:
And the module looks something like this:require mydir::mymod123; $result = mydir::mymod123::mysub();
The above works, but the "123" part could be any of hundreds or thousands of numbers, so I’ll store that number in $modno, and I can "require" the module like this:package mydir::mymod123; sub mysub { ...etc... return $x; } 1;
That seems to work, but how can I call mysub() now?$modno = 123; # Just for simplicity. Actually this number will +come from a database. require "mydir/mymod$modno.pm";
I’d like to avoid using a dispatch table please, because it could get very long, and I don’t want to have to modify the code each time a new module is added to mydir.
Also, if each module will always contain only 1 sub, do they need to have a sub at all? If not, how can they be written & called without a sub?
Thanks.
tel2
In reply to Call sub in variable module by tel2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |