[sf-perl] use {strict,warnings}

frosty biztos at mac.com
Mon Mar 3 03:43:56 PST 2008


I actually find it useful sometimes, but on average more annoying than useful.

The useful thing is that it reminds me to be clearer in things like printing and logging:

use strict;
use warnings;

my $nope = undef;
printf "You set it to '%s'\n", $nope;               # warns.
printf "You set it to '%s'\n", $nope || 'UNDEF';    # better.

But:

my $stuff = join( "fee", "fi", "fo", $nope );       # warns, annoying (to me).
die "$nope would be nice";                          # warns, annoying (to me).

On the one hand I wish undefined values could be auto-vivified to 'UNDEF' in warn and die, but on the other hand that's probably sqlplus poisoning my brain.

The problem, I find, with disabling warnings is that my list of annoying warnings may not be the same as my colleague's list.  That plus you have nobody to blame but yourself when you screw up.

The problem with *not* doing that is there is plenty of CPAN code that spews warnings all over your log files if you happen to have any.

-- f.


 
On Monday, March 03, 2008, at 12:45AM, "Joe Brenner" <doom at kzsu.stanford.edu> wrote:
>
>Kevin Frost <biztos at mac.com> wrote:
>
>> Least:
>>
>> Use of uninitialized variables.
>
>Yeah, that's a problematic one, isn't it?  Perl will happily do type
>conversions for you, but (if used in the recommended way, with strict
>and warnings) it nags incessantly about undefs, rather than just
>treating them as empty strings.
>
>Though it could be, of course, that the constant need to dance around
>this to silence suprious "unit" warnings is cleaning up my code in ways
>I don't appreciate.
>
>
>_______________________________________________
>SanFrancisco-pm mailing list
>SanFrancisco-pm at pm.org
>http://mail.pm.org/mailman/listinfo/sanfrancisco-pm
>
>


More information about the SanFrancisco-pm mailing list