[Catalyst-dev] Re: Annoying undef warnings from CP::Static::Simple

Aristotle Pagaltzis pagaltzis at gmx.de
Sat May 31 21:59:07 GMT 2008


* Jonathan Rockway <jon at jrock.us> [2008-05-31 20:30]:
> Just for the record, sometimes I think turning off warnings is
> better than "fixing" them, for example, I think:
> 
>   { no warnings;
>     if($foo eq 'bar'){ ... }
>   }
> 
> is easier to read than:
> 
>   if($foo && $foo eq 'bar'){ ... }
> 
> The second adds code that serves absolutely no algorithmic
> purpose, and I'm against that.

And the first one… doesn’t? An extra statement and an increase in
the level of indentation is not what I consider “no extra code.”

Not only that, but what you write will disable *all* warnings for
a possibly long stretch of code. A less sloppy way is to at least
say `no warnings 'uninitialized';`, but the right of doing this,
which also avoids the extra indentation, would be thus:

    if ( do { no warnings; $foo eq 'bar' } ) {
        # ...
    }

Except… this is harder to read than merely adding an extra truth
test. And it is often the case that proper local disabling of
warnings is more effort than just writing extra tests to avoid
triggering the warning(s).

But if you’re not going to disable them properly, then admit to
yourself that you don’t care and say so: put a `no warnings` at
the top of a scope or maybe at the top of the entire file and
move on. I have no problem with that; almost all my Perl files
have `no warnings qw( once qw );` at the top.

But pick either fish or fowl. Half-arsing it gives you all the
drawbacks of both approaches without any of the benefits.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>



More information about the Catalyst-dev mailing list