Just another Perl shrine | |
PerlMonks |
How do I import a global variable form a package with require?by nysus (Parson) |
on Jul 22, 2021 at 13:47 UTC ( [id://11135292]=perlquestion: print w/replies, xml ) | Need Help?? |
nysus has asked for the wisdom of the Perl Monks concerning the following question:
Monks, I was toying around with importing/requiring to improve my aptitude with them. So I have this package:
I want to use require to import the $var global. I try this:
This script throws Global symbol "$var" requires explicit package name (did you forget to declare "my $var"?). But I have no such error with Use A like so:
So I have a gap in my knowledge. I'm not sure why the second way works and the first doesn't. Any guidance is appreciated. Thanks!
$PM = "Perl Monk's";
Back to
Seekers of Perl Wisdom
|
|