Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Perl Programming guidelines/rules

by miki (Initiate)
on Nov 22, 2002 at 12:23 UTC ( #215077=note: print w/replies, xml ) Need Help??


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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://215077]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2022-10-01 07:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (126 votes). Check out past polls.

    Notices?