Well, it did generate a warning, didn't it?
Also, I have no idea what strict has to do with any of this.
I can't see any easy way to fix this either. The obvious thought at this point is that the language might try to guess that variable declarations with an initialization expression are meant to have a value before they are first accessed. But the obvious thought won't work.
What should happen here?
my $foo = undef;
That's gonna be undef on first access. You can construct more complicated scenarios using dynamically created lists where only partial evaluation will suffice to know which variables are supposed to be undef or not beforehand, like
my ($foo, $bar) = split " ", int rand 42;
And then this scheme still breaks down because the problem is not limited to compile time.
sub foo { baz(); my $foo = "bar"; sub baz { print $foo; } }
Although I'll grant that that's more likely to be a problem in PASCAL than Perl. :-)
Makeshifts last the longest.
In reply to Re: Mini-rant about 'strict'
by Aristotle
in thread Mini-rant about 'strict'
by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |