Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: dynamic loading modules

by fishmonger (Chaplain)
on Sep 03, 2012 at 15:36 UTC ( #991454=note: print w/replies, xml ) Need Help??

in reply to dynamic loading modules

Have you taken a look at using Module::Load::Conditional?

Replies are listed 'Best First'.
Re^2: dynamic loading modules
by sdetweil (Sexton) on Sep 03, 2012 at 15:44 UTC
    sorry, thats again off the mark..

    how do I code the source statement calling the function in the module AFTER I change from hard coded to dynamic loading?

    this part seems to be missing in any text I read..

    my app today uses

    my $os = Win32::GetOSName();

    there is NOT a 'use win32' anywhere.. I know, I coded it all. I don't know if there is some OTHER method loading this module.


    coding explicitly Win32::GetOSName() gets me into trouble, so I ASSUME I have to change the code.. to WHAT?

    just my $os=GetOSName() fails. how is the compiler supposed to set this up for dynamic resolution vs static? thats what I'm asking for.

      Unless I'm misunderstanding your goal, I don't see any reason why you can't use Module::Load or Module::Load::Conditional or a combination of both. Here's a simple test script which works for me.
      #!/usr/bin/perl use strict; use warnings; use Module::Load; my $os = 'Yet Unknown'; if ( $^O =~ /MSWin/ ) { load 'Win32'; $os = Win32::GetOSName(); } print $os;
      Output of my test: D:\perl>
        thx.. that works, but I don't understand 'why'.. how does the compiler know NOT to require the Win32 module in this case, but in my existing source, with no explicit use statement it does?

        anyhow.. now I have the same problem with TieRegistry <code> use Win32::TieRegistry; $Registry->Open(keyname);

        the doc says 'new(keyname)' should work, and then there are a bunch of functions off the handle..

        but I get Autoload is deprecated. or open not found.

        then must be some easy, clear way to handle this. without having to know the internals of every package.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991454]
[oiskuu]: Have you ever had your temperature taken from the other end?
[marto]: I read about a case where people were at a launderette, or whatever they're called in the US, and as a joke, put their toddler in with the washing, then closed the door
[Your Mother]: (Work in progress.)
[marto]: unaware that the model in question started the cycle automatically, provided the money/token had already been provided
[marto]: CCTV footage of the joke gone wrong is used in educational materials now IIRC
[ambrus]: oiskuu: definitely not silly. have you ever tried to remove cat hair or dog hair from clothes? for many clothes, it's pretty hard, and running the washing machine with a cat inside would get the hair on everything.
[oiskuu]: YM, I'm interested in your questions... maybe start a a thread at polls.
[oiskuu]: marto, it ended badly? I doubt the power is easy to plug at those installations?
[marto]: oiskuu sadly yes

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (14)
As of 2017-12-18 14:58 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (488 votes). Check out past polls.