As far as these variables go, my limits the scope in such a way that in a different module the variable isn't available.
No one's disputing that.
Here's a slightly more concrete usage, and two instances where the issue happens
You're creating instances of a class before the class's module has been executed, and you're blaming the module? Change
... package Problem; { ... 1; } package Main; ...
to
... BEGIN { package Problem; ... } ...
or move the code to a used file. use adds the BEGIN for you.
(By the way, the "1;" is useless, and you misspelled "package main;". And note how "package main;" is no longer needed when you move the package statement into the curlies.)
As for the second issue,
my $p1 = undef; BEGIN { $p1 = Problem->new('P11', 'P12', 'P13'); }
I've already stated I think you're obviously doing something wrong if you're initializing something twice.
In reply to Re^4: Use of uninitialized variables?
by ikegami
in thread Use of uninitialized variables?
by Zadeh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |