http://qs321.pair.com?node_id=215077


in reply to Perl Programming guidelines/rules

18.Did you consider using CVS?
28. I do not agree. If you leave out $_ you prohibit a vital perl feature.
30.If warnings are turned on you are warned about uninitialized values, aren't you?
Finally, there is perltidy, which formats your code according to your rules.

update (broquaint): title change (was $_)

Replies are listed 'Best First'.
Re: ($_) use warnings and uninitialized variables
by mt2k (Hermit) on Nov 22, 2002 at 23:08 UTC
    If warnings are turned on you are warned about uninitialized values, aren't you?
    That's one of the points of use warnings. If you are using uninitialized variables all over the place, then perhaps a review of the code is necessary. Below I have thrown together an example of two scripts that do the exact same thing... except that one produces warnings and one doesn't :)

    #!/usr/bin/perl # The 'bad' version - produces warnings use strict; use warnings; my $name; # perhaps some code to get user's name # { ... } print 'My name is ' . $name;
    #!/usr/bin/perl # The 'good' version - produces no warnings use strict; use warnings; my $name; # perhaps some code to get user's name # { ... } # The key line. Set a default value, even if blank. $name ||= ""; print 'My name is ' . $name;