[tpm] Seeking advice on using Perl in a professional way

Tom Legrady legrady at gmail.com
Mon May 8 18:14:13 PDT 2017

Boilerplate irritates me. I dislike starting every script with "use 
warnings; use strict" etc. So I came up with a module Boilerplate.pm. 
I've thought about putting it on CPAN, but it needs to change depending 
on the version of Perl you're using, and everyone would want their own 

You can see   what antique version of Perl I'm using .. this is the 
"modern" replacement for what's currently running on 5.6.1 - thanks Red Hat.

I probably shouldn't have utf8 in there, I don't think utf8 characters 
are going to get into stock & bond names, cusips, isins, and this week 
we were warned of the errors that can arise from combining utf8 & \d regex.

Since you mention PerlCritic, I used to create constants for punctuation 
characters, since PerlCritic warns you about them. And I do like the 
idea of defining constants at the top, rather than littering punctuation 
throughout the code. Since I was inconsistent about definition names, I 
wound up defining punctuation and the IO modes here as well. I'm still 
hoping to switch to a modern version of Perl, in which case there will 
be a longer list of modules, some of them different ... oh, to enable 
signatures and postderef!

package Boilerplate;

use warnings;
use strict;
use utf8;
use 5.010;

use autodie;
use Carp;
use Data::Dumper;
use English '-no_match_vars';
use FindBin '$Bin';
use File::Basename;

# All the variables defined in English


sub import {



     our $PUNC = ( ampersand => q{&}, at => q{@}, backslash => q{\\},
                             ... underscore => q{_}
     our %IO = ( append => q{>>}, delreadwrite => q{>+}, pipe_from => 
q{-|}, pipe_to => q{|-}
                         read => q{<}, readwrite => q{+<}, write => q{>}

     my $caller = caller(0);

     do {
            no strict 'refs';
            *{"$caller\:\:Bin"} = *{"FindBin::Bin};
         # and similar for Dumper, IO, PUNC
           *{"$caller\:\:$_"} = *{"English\:\:$_"} for @PERL_VARS;

I should probably have used *{"${caller}::Bin"} rather than escaping the 
colons, but it didn't occur to me at the time.

On 2017-05-04 08:24 PM, Harold Tessmann wrote:
> Hi from Michigan! Apologies if that’s a little far away for the 
> Toronto list, but the local pm.org <http://pm.org> mailing lists seems 
> a little dead.
> I'm looking to productionize some Perl scripts, and as such, I want to 
> adopt more structure than I use in disposable scripts. These scripts 
> would be used within the bounds of my employer, not released to the 
> general public (with maybe one or two exceptions). I know 
> that TIMTOWTDI, but I like the “sometimes consistency is not a bad 
> thing either” extension when it comes to common problems such as 
> command-line option parsing, and the perldocs don’t go in depth on 
> what people use in the real world. I’m looking for advice on topics 
> including, but not limited to:
> • Modern Perl: I like it in general, and I can install it on my team’s 
> machines. Are there reasons I shouldn’t use it?
> • Does anybody have a suggestion for a good blank script template? For 
> instance, I know I want "use Modern::Perl 'version';" or "use 
> warnings/strict;", etc., but there’s probably other things I would 
> want in a basic script. I’ve handled this in a sort of ad-hoc manner, 
> growing new scripts based on what I learned from the old, but I’d like 
> to build a good template once and be done with it. I’d also like the 
> template to include documentation, and that raises more questions. Is 
> there a reason to put my pod block near the top vs. the bottom? 
> Getopt::Tiny seems nice, including a feature to automagically build a 
> usage block—should I use that or is there a reason to avoid it? Or is 
> there a better option parser?
> • Do you run Perl::Critic on your code? I know I’ll disable some of 
> the rules, but is it more hassle overall than it’s worth? Similarly, 
> PerlTidy: it seems useful for generating HTML versions of 
> documentation, but I write code in a very precise way, such it would 
> take more time to configure it than I would save in reformatting.
> • Thus far I haven’t built anything complicated enough to warrant 
> figuring out an object library; I can get by with basic hash-based 
> structures. I’ve read a bit about Moose and Dancer: how do they 
> compare? And what else is widely-used that I should consider?
> Any advice is greatly appreciated.
> Thanks,
> Harold
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20170508/db921902/attachment.html>

More information about the toronto-pm mailing list