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
In reply to Re: Inheritance based on input
by Corion
in thread Inheritance based on input
by cbanker
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |