ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/common-sense/sense.pm.PL
(Generate patch)

Comparing common-sense/sense.pm.PL (file contents):
Revision 1.4 by root, Thu Apr 15 23:46:22 2010 UTC vs.
Revision 1.7 by root, Fri Jan 14 06:46:29 2011 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines