Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: dynamic loading modules

by sdetweil (Sexton)
on Sep 03, 2012 at 15:19 UTC ( #991449=note: print w/replies, xml ) Need Help??


in reply to Re: dynamic loading modules
in thread dynamic loading modules

thx.. I added this to my begin block
if ($^O eq "MSWin32") { print ("begin\n"); my $win32 ="Win32.pm"; require $win32; import $win32 qw(GetOSName); }
I get the print message fom my begin block code. and still call it
my $os = GetOSName();
and it still fails
Undefined subroutine &main::GetOSName

Replies are listed 'Best First'.
Re^3: dynamic loading modules
by chromatic (Archbishop) on Sep 03, 2012 at 18:07 UTC

    This is never going to work:

    my $win32 ="Win32.pm"; import $win32 qw(GetOSName);

    If there isn't already an import() in your current package, this will effectively become:

    'Win32.pm'->import( 'GetOSName' );

    Because there's no package called Win32.pm, nothing will get imported. You're better off writing:

    Win32->import( 'GetOSName' );

    ... or even:

    'Win32'->import( 'GetOSName' );
Re^3: dynamic loading modules
by choroba (Chancellor) on Sep 03, 2012 at 19:39 UTC
    The line calling GetOSName() should never be called on any system other than Windows. Fix the logic of your program.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991449]
help
Chatterbox?
[atcroft]: james28909: That particular questions was a bit of trick, actually (depending on the country you are in). More interesting is, if you are trying to subtract from an epoch time, for instance, you might have to consider when/if DST occurs for a location,
[atcroft]: because you may have to adjust the number of seconds you change from an epoch from 86400 (not to mention leap seconds)....
[atcroft]: james28909: Although if your program is using a database, you might be able to "pass the buck" to the database and ask it to do the date change for you....
[stevieb]: ++ atcroft

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2017-04-29 04:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (531 votes). Check out past polls.