1
| 7
| Know the documentation. Be able to find anything in it.
|
2
| 10
| To get started with the Perl documentation, type perldoc perl.
|
3
| 18
| First know yourself, then your programs will be easier to know.
|
4
| 20
| Motivate yourself by what you want to move toward, not what you want to get away from.
|
5
| 28
| If you can't say it in natural language, you won't be able to say it in Perl.
|
6
| 30
| Use a consistent style for each project.
|
7
| 39
| Comment the hard parts. Use POD.
|
8
| 44
| Declare as many of your variables as possible to be lexical.
|
9
| 46
| Use -w and use strict in all your programs.
|
10
| 46
| Use use diagnostics to explain error messages.
|
11
| 49
| Create variables in the innermost scope possible.
|
12
| 55
| If you have many explicit references to the same instance of $_, use a named variable instead.
|
13
| 57
| When using a while loop that sets $_, localize $_ first if it might be called from elsewhere.
|
14
| 61
| Put empty parentheses after a function that could take arguments but doesn't.
|
15
| 66
| Use parentheses when in doubt about precedence; they won't hurt.
|
16
| 69
| Before testing the existence of a lower-level hash key, test the existence of the higher-level keys if there's a chance they may be absent.
|
17
| 70
| Eliminate all causes of warning messages in a program before proceeding with further development.
|
18
| 73
| Declare subroutines early, avoid collisions with the Perl built-in functions, or call them with &.
|
19
| 76
| Don't pass arrays to built-in functions which normally expect a scalar.
|
20
| 76
| Don't rely on loop variables retaining their values after the loop; save them explicitly if you need them.
|
21
| 80
| Use the Data::Dumper module to print out a formatted dump of any variable or hierarchical data structure.
|
22
| 84
| Migrate option setting to the most convenient input interface possible.
|
23
| 95
| Use one-liners for rapid prototyping of small code constructs.
|
24
| 112
| Examine references to hashes instead of the hashes themselves in the debugger to get well-formatted output.
|
25
| 130
| The actual syntax error in your program could occur not just on the line reported by Perl, but on any line preceding it.
|
26
| 136
| Handle only the first warning or error message output by Perl; don't bother reading the others, just recompile.
|
27
| 148
| Don't enter the same text in different places in a program and depend on having to keep them in sync.
|
28
| 150
| Force as many errors as possible to occur at compile time rather than at run time.
|
29
| 153
| Know your operating system.
|
30
| 157
| Bullet-proof your program by trapping exceptions and handling them gracefully.
|
31
| 163
| readdir() returns the list of filenames in the directory, but they are not qualified by the directory itself
|
32
| 166
| The Deparse module can often explain how perl is parsing your code.
|
33
| 170
| Never qualify a my statement with a condition.
|
34
| 174
| Optimize your code for readability and maintainability first; make performance optimizations only after profiling of a working version demands it.
|
35
| 181
| Use the Benchmark module to compare the relative speeds of different code strategies.
|
36
| 185
| Use Devel::DProf to profile programs for bottlenecks.
|
37
| 185
| Inside a loop, take every opportunity to get out of it as early as possible.
|
38
| 187
| Memoize function calls with common arguments.
|
39
| 189
| Do everything possible in Perl rather than calling external programs.
|
40
| 191
| Don't form unnecessary lists.
|
41
| 193
| Avoid unnecessary copying.
|
42
| 194
| Avoid temporary files.
|
43
| 201
| Put common sets of constants in their own modules using the Exporter, and use the modules where needed.
|
44
| 212
| If at all possible, get an interactive login on the Web server for which you are developing. If you can't, consider using a different service.
|
45
| 217
| Create CGI programs with taint checking from the beginning. Retrofitting -T onto existing programs is tedious and frustrating.
|
46
| 218
| Run your CGI program from the command line to check that it produces the right output in the right order.
|