http://www.perlmonks.org?node_id=959758


in reply to Re^8: can't import using exporter
in thread can't import using exporter

I tried to hint at you that you should put in more effort into making it easy for other people to reproduce your problem. The easier it is for people to reproduce your problem and to inspect your code, the more likely it is that a solution or a workaround will be presented.

Dumping the whole code, littered with stuff inconsequential to the problem, like Readonly and weird aliasing, is not what I call effort, and it also does not help in making the problem obvious. This is menial work that you should have done yourself instead of running around in circles and screaming that you are the only person in the world who has encountered this bug in 5.14.x. Whenever you feel that you are the only person to have found a fundamental bug in a language, or in a compiler, I recommend doubting your own understanding of the matter instead of running around and claiming you have found the bug and everybody ignores you. Also see I am great at communicating, but people are bad at listening. If you feel that nobody understands you, it is far more likely that your communication is bad, than that people are bad at listening.

That you think that "use module" should do what you want is your prerogative. If you want to use Perl instead of your fantasy language though, it behooves you to read use to actually see what the use keyword does. Understanding that, and learning about how Perl exporting and symbol aliasing works will then also help you understand why your attempt fails as it does and why the BEGIN shehanigans are neccesary if you want to keep the rest of your program structure as is.

Personally, I recommend splitting up the program into separate files and not relying on weird initialization dances like first initializing lexical variables, just to initialize global variables from them. Again, see App::fatpacker if you are hell-bent on producing a single file after developing your program.