Ten ways Perl programmers mess up their lives

Ten ways Perl programmers mess up their lives

我在effective perl里摘录下的,大家快对照自己看看吧


(10) They keep using Perl 4
         Perl 4 is dead. Long live Perl 5. If you are thinking of buying a CGI programming book, make sure
        it uses Perl 5. You don‘ want one that uses cgi-lib.pl, calls all its subroutines with the
        &func() syntax, and doesn’t tell you anything about all the wonderful Perl modules that have been
        written in the past half decade.

(9) They confuse list and scalar context
         Remember that operators work differently, sometimes very differently, depending on the context
        they’re used in.
         For example, ?¡ãBoolean?¡À contexts like the condition of a while loop are scalar. while (1..10)
        {?-} means something entirely different than foreach (1..10) {?-}
         Or the difference between my ($foo) = @bar and my $foo = @bar

(8) They don’t understand regular expressions
         You can’t write Perl effectively without understanding and using regular expressions

(7) They omit (too much) punctuation
         Leaving out semicolons, commas, closing quotes, and/or parentheses can produce very strange
        error messages, or sometimes silent misbehavior
         For example, don’t forget the semicolon after an eval block or anonymous sub
         Don’t omit parentheses around arguments of || (better, use or instead)

(6) They don’t read their error messages
         When a program dies, always look at the first error message and/or warning issued
         When you return to the program source code, go to the line number mentioned in the error
         The error in the code is either at or before that line?not after

(5) They write fragile programs
         Always check return status from open, opendir, and other system calls
         Avoid using relative paths and shell metacharacters in backticks, system/exec, and pipe opens
         Avoid using non-portable code when a module exists to do the same thing portably

(File::Basename, Cwd, etc.)

(4) They bite off too much at once
         Learn to write two- or three-line programs to test features
         Or use perl -e 'insert Perl code here', or use the debugger as a Perl shell

(3) They reinvent the wheel
         Have an ordinary CGI or network programming task? It’s in the CPAN
         Perl modules have been tested, used, and (usually) thoughtfully designed, too
         You can get a lot done in a half dozen lines of Perl, especially if they just run someone else’s code

(2) They don’t read the documentation
         Read the Perl man pages, especially perlfunc
         Use perldoc to read stuff your man command can’t see
         Read any (good) Perl books you can ?nd

(1) They don’t use strict or -w
         There is very little sympathy for a Perl programmer who has a problem that -w would have caught
         -w is a pain sometimes, but it will catch many, many, many careless errors
         use strict helps you write better-designed programs
         Okay if you don’t bother in programs a few lines long, but always use them both otherwise?
        especially when embarking on a big new project (denition of ?¡ãbig?¡À varies according to skill level
        :-)

没排格式,看着费眼睛
崩溃了,里面有些字符很奇怪。。
我要改正改正

楼主可以时不时的发给这样的文章

这些算是perl rule,我们可以随时review一下,这对我们的编程很有好处

感谢分享
学perl就得细心
好像学什么语言都得细心。呵呵
They reinvent the wheel  
They don’t read the documentation
They don’t use strict or -w