Nathan Torkington wrote:
> 
> Turning Perl into a nagging harpie means that the really important
> warnings will be ignored.
> 
> This line of thinking brought to you by Mark-Jason's excellent talk
> on data typing.

I agree, and just read MJD's paper the other day (nice job, BTW), but
unfortunately there are a couple warnings that are really on the edge of
nagging already, specifically:

   Use of uninitialized value in concatenation (.) at line 32

Brought to you by the lovely:

   print "Welcome back, $first $middle $last!\n";

How neat. Who else hates this? It's enough to drive me batty, and smacks
of the useless typecasts needed to shut C up.

Thankfully, Perl 5.6 allows you to say:

   no warnings 'uninitialized';

But unfortunately you then have to block this off:

   {
      no warnings 'uninitialized';
      print "$some $stuff\n";
   }

Or put it in your whole code up at the top, in which case you miss out
on potentially useful uninitialized variable warnings just to maintain
your sanity (or make your CPAN module look clean).

My question: What good is this warning in most contexts, anyways?
Really. Honestly. If you cared about the value, you would already be
checking it, right? Probably with something like this:

   die "Fatal: Can't continue with \$var unset!" unless $var;

Perl should stop nagging about this. Perl should be smart and not bother
you about uninitialized values in the following situations:

   - string concat
   - string comparison

Warning me that in:

   $z = $x + $y;
   $z = --$x;
   do_stuff() unless ($x < 5);

$x is uninitialized is probably a good idea, because of the nature of
numeric ops. But telling me:

   $name = $NAME unless ($name eq $local_name);

$name is uninitialized in the string eq is a waste. These warnings just
annoy, since in order to take advantage of them you have to put explicit
catches in your code anyways, like:

   $name = $NAME unless ($name eq $local_name);
   die "Fatal: Couldn't determine name!" unless $name;

And notice this is at a completely different logical point than the
warning would harp at. That's my($.02), if anyone agrees I'll write an
RFC (but I suspect my legs are about to be cut off :).

-Nate

Reply via email to