1 | #! perl |
1 | #! perl-000 |
2 | |
2 | |
3 | open STDOUT, ">$ARGV[0]~" |
3 | open STDOUT, ">$ARGV[0]~" |
4 | or die "$ARGV[0]~: $!"; |
4 | or die "$ARGV[0]~: $!"; |
5 | |
5 | |
6 | our $WARN; |
6 | our $WARN; |
… | |
… | |
14 | use utf8; |
14 | use utf8; |
15 | use strict qw(subs vars); |
15 | use strict qw(subs vars); |
16 | |
16 | |
17 | no warnings; |
17 | no warnings; |
18 | use warnings qw(FATAL closed threads internal debugging pack malloc portable prototype |
18 | use warnings qw(FATAL closed threads internal debugging pack malloc portable prototype |
19 | inplace io pipe unpack regexp deprecated exiting glob digit printf |
19 | inplace io pipe unpack deprecated glob digit printf |
20 | layer reserved taint closure semicolon); |
20 | layer reserved taint closure semicolon); |
21 | no warnings qw(exec newline unopened); |
21 | no warnings qw(exec newline unopened); |
22 | |
22 | |
23 | BEGIN { |
23 | BEGIN { |
24 | $H = $^H & ~$H; |
24 | $H = $^H & ~$H; |
… | |
… | |
54 | # |
54 | # |
55 | # use utf8; |
55 | # use utf8; |
56 | # use strict qw(vars subs); |
56 | # use strict qw(vars subs); |
57 | # use feature qw(say state switch); |
57 | # use feature qw(say state switch); |
58 | # no warnings; |
58 | # no warnings; |
59 | # use warnings qw(FATAL closed threads internal debugging pack malloc |
59 | # use warnings qw(FATAL closed threads internal debugging pack |
60 | # portable prototype inplace io pipe unpack regexp |
60 | # portable prototype inplace io pipe unpack malloc |
61 | # deprecated exiting glob digit printf layer |
61 | # deprecated glob digit printf layer |
62 | # reserved taint closure semicolon); |
62 | # reserved taint closure semicolon); |
63 | # no warnings qw(exec newline unopened); |
63 | # no warnings qw(exec newline unopened); |
64 | |
64 | |
|
|
65 | |
65 | =head1 DESCRIPTION |
66 | =head1 DESCRIPTION |
|
|
67 | |
|
|
68 | “Nothing is more fairly distributed than common sense: no one thinks |
|
|
69 | he needs more of it than he already has.” |
|
|
70 | |
|
|
71 | – René Descartes |
66 | |
72 | |
67 | This module implements some sane defaults for Perl programs, as defined by |
73 | This module implements some sane defaults for Perl programs, as defined by |
68 | two typical (or not so typical - use your common sense) specimens of Perl |
74 | two typical (or not so typical - use your common sense) specimens of Perl |
69 | coders. In fact, after working out details on which warnings and strict |
75 | coders. In fact, after working out details on which warnings and strict |
70 | modes to enable and make fatal, we found that we (and our code written so |
76 | modes to enable and make fatal, we found that we (and our code written so |
… | |
… | |
95 | program and there are no advantages to not reporting this, so malloc |
101 | program and there are no advantages to not reporting this, so malloc |
96 | warnings are fatal by default. |
102 | warnings are fatal by default. |
97 | |
103 | |
98 | =back |
104 | =back |
99 | |
105 | |
|
|
106 | Unfortunately, there is no fine-grained warning control in perl, so often |
|
|
107 | whole groups of useful warnings had to be excluded because of a single |
|
|
108 | useless warning (for example, perl puts an arbitrary limit on the length |
|
|
109 | of text you can match with some regexes before emitting a warning, making |
|
|
110 | the whole C<regexp> category useless). |
|
|
111 | |
100 | What follows is a more thorough discussion of what this module does, |
112 | What follows is a more thorough discussion of what this module does, |
101 | and why it does it, and what the advantages (and disadvantages) of this |
113 | and why it does it, and what the advantages (and disadvantages) of this |
102 | approach are. |
114 | approach are. |
103 | |
115 | |
104 | =head1 RATIONALE |
116 | =head1 RATIONALE |
… | |
… | |
257 | |
269 | |
258 | =cut |
270 | =cut |
259 | |
271 | |
260 | package common::sense; |
272 | package common::sense; |
261 | |
273 | |
262 | our $VERSION = '3.2'; |
274 | our $VERSION = '3.4'; |
263 | |
275 | |
264 | # overload should be included |
276 | # overload should be included |
265 | |
277 | |
266 | sub import { |
278 | sub import { |
267 | IMPORT |
279 | IMPORT |
… | |
… | |
426 | usefulness of some warnings over others. This module is aimed at |
438 | usefulness of some warnings over others. This module is aimed at |
427 | experienced Perl programmers, not people migrating from other languages |
439 | experienced Perl programmers, not people migrating from other languages |
428 | who might be surprised about stuff such as C<undef>. On the other hand, |
440 | who might be surprised about stuff such as C<undef>. On the other hand, |
429 | this does not exclude the usefulness of this module for total newbies, due |
441 | this does not exclude the usefulness of this module for total newbies, due |
430 | to its strictness in enforcing policy, while at the same time not limiting |
442 | to its strictness in enforcing policy, while at the same time not limiting |
431 | the expresive power of perl. |
443 | the expressive power of perl. |
432 | |
444 | |
433 | This module is considerably I<more> strict than the canonical C<use |
445 | This module is considerably I<more> strict than the canonical C<use |
434 | strict; use warnings>, as it makes all its warnings fatal in nature, so |
446 | strict; use warnings>, as it makes all its warnings fatal in nature, so |
435 | you can not get away with as many things as with the canonical approach. |
447 | you can not get away with as many things as with the canonical approach. |
436 | |
448 | |