in reply to Writing Plugin-Able perl scripts
Try something like the following
If there's a possibility that the required module might not be present, you can wrap the require in an eval.if ( $^O =~ /win32/i ) { require MySysInfo::Win32; import MySysInfo::Win32; } elsif ( $^O =~ /amiga/i ) { require MySysInfo::Amiga; import MySysInfo::Amiga; } elsif # etc.
The import gives you a chance to export a common API into the top-level script's namespace (you'll need to implement an import sub in each of your packages -- examples of that abound).
Enumerating $^O is left as an exercise.
|
|---|