Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How to call a Sub / Function with changing name

by kcott (Archbishop)
on Oct 29, 2010 at 01:08 UTC ( [id://868196]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://868196]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2026-02-18 00:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.