Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 55 lines (34 sloc) 1.821 kb
d5f3b1b @petdance Importing from Andy original repo
authored
1 =head1 IT'S A TRAP!
2
3 =head2 while(<STDIN>)
4
5 Be very careful of this! If somehow, you were to get a false value
6 (e.g. an empty line, or a line with only a zero on it), your file
7 would stop processing. This doesn't normally happen if you're dealing
8 with file reading (unless you've modified C<$/>), but it's possible.
9
10 You're more likely to run into this:
11
12 while(readdir(DIR)) {
13
14 If you have a file name of C<0>, your program will stop and not continue
15 processing files.
16
17 A more appropriate C<while> loop looks like this:
18
19 while ( defined( my $line = <STDIN> ) ) {
20 while ( defined( my $file = readdir(DIR) ) ) {
21
22 =head2 arrays are not hashes: $a[time()]++;
23
24 If you are using arrays with large numbers, Perl will create an array
25 of that size automatically. Thus, if you're trying to make a count
26 of things that happened during a particular second, avoid the temptation
27 of using L<perlfunc/time> as an array key.
28
29 Perl does not support sparse arrays. The closest thing is a hash.
30
31 =head2 DateTime::TimeZone (!)
32
33 If you're like me, you either installed the L<DateTime> module for
34 a specific need, or you had it installed as part of your OS.
35
36 Did you know there's a seperate dependency, called L<DateTime::TimeZone>,
37 that is a dump of time zone data?
38
39 If C<DateTime> can't figure out your time zone environment, it uses
40 C<DateTime::TimeZone>, which can be years out of date!
41
42 Update your C<DateTime::TimeZone> today!
43
44 =head2 Time::HiRes might not be
45
46 Don't depend on L<Time::HiRes> for millisecond (or smaller) calculations.
47
48 Some systems have a C<clock_getres> that can only go to hundredths of a
49 second, even in this day and age - a recent installation of Red Hat
50 Enterprise Linux 4 on an AMD 64 platform provided only that level of
51 granularity.
52
53 So, check your target's C<Time::HiRes> before relying on it.
54
Something went wrong with that request. Please try again.