in reply to How to call a Sub / Function with changing name
If that's for a one-off script, you appear to have your answer. For a solution that's to be used in the longer term, you might consider something along the lines of the following skeleton code:
In a module, say Medical.pm:
package Medical; sub new { ... } sub allergies { ... } sub immunizations { ... }
Then, in your script:
use Medical; my $medical = Medical->new(); ... $medical->$filename(); ...
When you later need to process a new file, say diseases, you don't need to update a dispatch table or change your script in any way. Just add sub diseases { ... } to Medical.pm.
-- Ken
|
|---|