Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Runtime module use and sub definitions

by CukiMnstr (Deacon)
on Apr 03, 2002 at 21:32 UTC ( [id://156454]=note: print w/replies, xml ) Need Help??


in reply to Runtime module use and sub definitions

you could also use an init sub, where you require the modules you need, and set some variables to the different subs...

note: I have not tested this code, and I haven't done any cross-platform scripting that requires something like this, I just remembered seeing this technique in Perl For System Administration by David N. Blank-Edelman (ORA).

sub Init { use Common::Module; my ($common_var01, $common_var02) = ($foo, $bar); if ($^0 eq "MSWin32") { require Win32::Baz; require Win32::Quux; common_sub01 = "common_sub01_nt"; common_sub02 = "common_sub02_nt"; } else { require Foo; common_sub01 = "common_sub01_unix"; common_sub02 = "common_sub02_unix"; } } sub common_sub01_nt { ... } sub common_sub01_unix { ... } # main program # (where we call the subs) &$common_sub01($foo, $bar) if $foobar;

hope it helps,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-26 02:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found