Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Well, after hours of attempting everything, including changes to ALL of my scripts with attempts at using "do" per the suggestion made here: Re: Exporting all variables and subroutines using Exporter, attempts at using 'require' for a .pl file, or using 'use' for a package (.pm) file that was setup in package format and exporting ALL of the variables (a rather long list, but apparently there is not simple way to export everything without listing them all individually--so everything was repeated, manually); I have come to the point that I believe this solution does not work. At least, not while using strict. Once again, strict is uselessly a monkey wrench in the works, stopping the script at compile time when it hadn't even had a chance yet to find the variable declarations. This is a problem. I was declaring the variables within the module/file that I was then referencing within the script--at the top of it, too--yet the compiler does not traverse the modules in time to prevent compile-time errors by strict.

I have to ask--did you REALLY get this to work just as you have prescribed above in your own code?

Whether or not you did, it doesn't work for me, and I'm left with looking at options for combining everything into one single file again. AARGH! Why does Perl have to be such a pain! Okay. I can just avoid the strict pragma. But then strict is shooting itself in the foot to tell me about problems that don't actually exist before it even has a chance to discover the fact. Basically it shuts down compilation before finding the variable declarations that it's saying do not exist--when they do exist in the package.

I don't think 'strict' was designed to work on a multi-file perl script. I have yet to find a way to keep it happy without declaring every global variable in every single file of the script. My current "GlobalVars.pm" package contains around 450 lines of code. I'm not eager to repeat that 18 times, totally redundantly, in every single file of the script when those should be GLOBAL to begin with and not have to be REDECLARED every single time they get used AGAIN. I guess my mind is illogical, but to declare something means it did not previously exist--so I should not have to declare again things which have already been declared as globals.

Blessings,

~Polyglot~


In reply to Re^2: How to import "global" variables into sub-scripts from main script? by Polyglot
in thread How to import "global" variables into sub-scripts from main script? by Polyglot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2024-04-25 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found