5 minimums for any perl script?

Abigail abigail at abigail.be
Mon Jan 30 10:01:49 GMT 2012


On Sun, Jan 29, 2012 at 06:34:06PM -0500, Joseph Werner wrote:
> >> So if Perl Best Practices is too much, and you could only have 5 rules
> >> for any perl script, what would they be?
> >  ...
> > 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 will agree with always 'use strict', I have never [yet] had to not
> 'use warnings' AFTER development.

Funny. If I have to pick between strict and warnings in production, I'd
pick warnings each and every time. 

I cannot remember ever having something in production which is then tripped
by the run time effects of strict (except trying to dereference an undefined
value, but see next sentence). But I see the run time effects of warnings
(usually in the form of "uninitialized value") all the time.

Now, the compile time effects of "use warnings", I can easily live without.
In fact, some of them I disable right away; I always follow my "use warnings;"
by a "no warnings 'syntax';".

> Explicitly stating minimum Perl version requirement does not rise to
> the same level of concern as  'use strict'  and 'use warnings'.  How
> often do you regression test to know the minimum Perl version
> requirement anyhow?


It depends who the code is for *and* for its side effects. For $WORK code,
I don't bother with supplying a version. We're on 5.8.5; writing code that
doesn't work with it is pointless, and we have to plans to revert to 5.6.

However, soon we should be on 5.14.x. Then I'll be using "use 5.010" (or
some higher number), but not so much as to signal a minimum version. But
since 5.010, "use 5.XXX" will have side effects. In particular, "use 5.010"
enables the "say", "given" and "state" features.

For CPAN code however, I typically do supply a "use $MINIMUM_VERSION" to
signal the minimem required version. And I do have some old perls on my
system so I can test against them.



Abigail


More information about the london.pm mailing list