Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Wrong + Right = Even Worse (do)

by tye (Cardinal)
on Apr 04, 2014 at 06:17 UTC ( #1081068=note: print w/ replies, xml ) Need Help??


in reply to Wrong + Right = Even Worse

To load a non-module Perl file unconditionally, you should use do, not require. (Even better is to (eventually) convert things to real modules, of course.)

- tye        


Comment on Re: Wrong + Right = Even Worse (do)
Re^2: Wrong + Right = Even Worse (do)
by choroba (Abbot) on Apr 04, 2014 at 07:34 UTC
    That depends on what the pseudo-modules do. Most of them define subs and initialize global variables, so do wouldn't be much better - at least in the pseudo-modules. It might work in the OO module, though.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Most of them define subs and initialize global variables, so do wouldn't be much better

      The problem you reported was that one module was including non-modules in order to get those subroutines defined in its package and that broke other places that still wanted those subs defined in their package (main).

      do would fix the problem you reported.

      - tye        

        do runs the file always, but it does update %INC if it finds it. Therefore, it might not solve the problem.
        لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-08-29 18:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (286 votes), past polls