Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re: Coding for two platforms in one Script

by BoredByPolitics (Scribe)
on Dec 05, 2001 at 22:24 UTC ( #129696=note: print w/replies, xml ) Need Help??


in reply to Re: Coding for two platforms in one Script
in thread Coding for two platforms in one Script

The problems with require are that for the Win32::EventLog module (at least) you get lots of 'undefined' errors (with and without -w) when the module is required (although it does continue to run, but makes examining the legitimate output of the script problematic). I also understand that I need to require in each BLOCK that uses functions from that module, well, if I don't I get more compilation errors! I get the impression that I'm incurring more overhead by doing so.

I was unsure about the import function - do I need to use that in every BLOCK that the require appears in?

Thanks for your (and everyone elses!) reply :-)

Pete

  • Comment on Re: Re: Coding for two platforms in one Script

Replies are listed 'Best First'.
Re: Re: Re: Coding for two platforms in one Script
by perrin (Chancellor) on Dec 05, 2001 at 23:20 UTC
    You shouldn't get any errors when the module is required unless it has bugs. Are you talking about undefined variable errors, or are you using subroutines imported from the module during a use()?

    There is no need to require the module in each block. Just require it once. If you are using imported subs, you will need to import it once in each module that uses those subs.

    It's hard to understand why you're getting these errors, so maybe you should try to post a small example of some code that gives you errors when you use require.

      I finally worked out what was causing the 'undefined variable' errors, and have resolved them.

      The POD docs for Win32::EventLog imply that you can leave undefined variables which you don't want to use. This is true, from a functional perspective, but the module itself doesn't check that everything it's putting into a subroutine call is defined, hence the errors.

      So the solution (for this module) is to either define the variables in the Report call properly, or set them to null/zero. I've also found that I need to set the machine name in the new() call, otherwise it also generates an undefined error.

      You live and learn ;-)

      Pete

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2022-01-25 04:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (65 votes). Check out past polls.

    Notices?