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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.