Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Inheritance based on input

by Corion (Pope)
on Oct 06, 2010 at 19:31 UTC ( #863857=note: print w/ replies, xml ) Need Help??


in reply to Inheritance based on input

use won't work here. Look at require (and import). By using something like the following, you can import modules and call functions in them on demand:

... if ($device =~ /^(Device1|Device2)$/){ require "$device.pm"; $device->import(); # import the device subroutines here } ... # This assumes all devices have and export the same subroutine names device_function_1(); device_function_2();

Update: Fixed typo in regex, thanks to Perlbotics


Comment on Re: Inheritance based on input
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2014-07-30 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (237 votes), past polls