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

Re^2: How to import "global" variables into sub-scripts from main script?

by Polyglot (Friar)
on Apr 07, 2021 at 23:24 UTC ( #11130980=note: print w/replies, xml ) Need Help??


in reply to Re: How to import "global" variables into sub-scripts from main script?
in thread How to import "global" variables into sub-scripts from main script?

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^2: How to import "global" variables into sub-scripts from main script?

Replies are listed 'Best First'.
Re^3: How to import "global" variables into sub-scripts from main script?
by haukex (Bishop) on Apr 08, 2021 at 15:12 UTC
    using 'use' for a package (.pm) file that was setup in package format and exporting ALL of the variables ... I have come to the point that I believe this solution does not work.

    This solution should work; the first code sample posted by bliako above works fine for me. If you have trouble with it, please have a look at How do I post a question effectively? and post a Short, Self-Contained, Correct Example that reproduces the trouble you're having.

    I don't think 'strict' was designed to work on a multi-file perl script.

    That is not the case.

    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.

    First: strict enforces certain rules. One of the things these rules do is help avoid certain coding mistakes that become debugging and maintenance nightmares. One reason many people here are telling you to use strict is because they speak from experience; they've had to deal with such situations themselves and it's cost them time/money. Those people with enough experience with Perl know in which rare situations it's ok turn off strict, and they can explain exactly why. But here's the thing: unfortunately, the fact that you are having the troubles you are describing in this thread is a good indicator that perhaps your Perl experience is not at that level yet, which means your time is likely better spent on learning how to code with strict turned on first.

    Second: People on PerlMonks are volunteering their time to help others for free. When someone comes asking for help with a script that doesn't use strict, then one of the first debugging steps is to turn on strict and warnings to see if the aformentioned coding mistakes are present in the code. And once the code works under strict, there isn't really a good reason to turn it back off. Of course you're free to do so, but at the same time please understand that refusing to use strict also means that you are refusing to follow one of the main debugging suggestions people are giving you, which among other things could be considered disrespectful of those trying to help.

    I also wanted to note that you've made 18 posts in this thread, but only one of them contains more than a single line of code. My suggestion would be that you show the issues you're having with an SSCCE, so that we have something to actually work with and help you improve.

    The above are the reasons why people are being so insistent that you use strict. If you give it a chance, we'll be happy to help you learn - hence my requests for an SSCCE above.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2021-09-17 06:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?