5 minimums for any perl script?

Mark Fowler mark at twoshortplanks.com
Mon Jan 30 16:28:46 GMT 2012


On Sun, Jan 29, 2012 at 11:11 PM, Damian Conway <damian at conway.org> wrote:

> 3. Strictures: Always 'use strict' (and 'use warnings' during development) and
>   explicitly state your minimum Perl version requirement. (e.g. 'use v5.10')
>   [Ch18: "Strictures", "Warnings"]

I'd point out that if you state a reasonably modern version of Perl
you don't need to turn on strict, it's turned on for you.  If you use
Moose (or several other modules out there) then warnings get turned on
for you too.

At $work in our key codebase we find demanding all these strictures
tiresome.  We instead have a standard line that you need to put this
into your source:

 use OurSecretProjectName::Strict;

(If you don't the test suite will fail and our build system will get
angry with you.)  This module turns on a bunch of handy strictures:

package OurSecretProjectName::Strict;

use strict;
use warnings;
no indirect 0.24 ":fatal";
no multidimensional 0.008;
use Sub::StrictDecl 0.003;

sub import {
        strict->import;
        warnings->import;
        indirect->unimport(":fatal");
        multidimensional->unimport;
        Sub::StrictDecl->import;
}

sub unimport {
        strict->unimport;
        warnings->unimport;
        indirect->import;
        multidimensional->import;
        Sub::StrictDecl->unimport;
}

1;



More information about the london.pm mailing list