|Do you know where your variables are?|
Re^3: How to import "global" variables into sub-scripts from main script?by haukex (Archbishop)
|on Apr 08, 2021 at 15:12 UTC ( #11131009=note: print w/replies, xml )||Need Help??|
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.
In Section Seekers of Perl Wisdom