CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Regarding perl intepretation.

 



rgdutta
Novice

Jun 7, 2004, 3:11 AM

Post #1 of 2 (859 views)
Regarding perl intepretation. Can't Post

Hi

I have a strange problem.

I have perl modules which are platform specific.But there is a file which contains functions of which some are used by some of the platform specific modules.Eg let HP.pm is the HPUX module and win.pm the windows specific module.Let the common module be X.pm

In HP.pm and win.pm i have the following line of code.

use X qw(:Hp); ---> this is in HP.pm this module uses some func abc() in X.pm

use X qw(:win); ----> this is in win.pm this module uses some function def() in X.pm.This has windows specific stuff.

when i try to tun my program on a HPUX box why does the intepreter try to load some windows modules in X.pm eventhough this is run on the HPUX box and throws error.....

Can some Perl Guru Help...

Thanx

Guru Dutta


davorg
Thaumaturge / Moderator

Jun 8, 2004, 1:04 AM

Post #2 of 2 (853 views)
Re: [rgdutta] Regarding perl intepretation. [In reply to] Can't Post

I think we probably need to see the code in X.pm that loads the other modules.

If you're using code like this:

Code
if ($hp) { 
use Some::HP::Module;
}

if ($win) {
use Some::Win::Module;
}


Then that doesn't do what you think it does. It will always try to load both of the modules. This is because "use" is executed at compile time and the $hp and $win variables aren't given values until run time.

You probably want to look at using "require" and "import" instead.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives