in reply to Re^3: Use of uninitialized variables?
in thread Use of uninitialized variables?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Use of uninitialized variables?
by Glav (Novice) on Jun 12, 2008 at 19:31 UTC | |
by ikegami (Patriarch) on Jun 12, 2008 at 19:57 UTC |