Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: PM vs PL

by choroba (Cardinal)
on Nov 20, 2020 at 22:34 UTC ( [id://11123946]=note: print w/replies, xml ) Need Help??


in reply to PM vs PL
in thread Autovivification with require

I came late to the Perl game, but I've met required pl files in very old code. So I'd guess the best practice has changed.

Update: I even discussed it here.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: PM vs PL
by Bod (Parson) on Nov 20, 2020 at 22:47 UTC

    Yeah...I'm guilty of learning what I needed to learn to make things work, then not learning much else until I needed to make something else work. So having learnt to require *.pl files, I have just kept doing it.

    Maybe I could claim I write fashionably retro code :P

      My first reaction on seeing require of a .pl file is that it is very old code. I would call it a code smell.

      I prefer to put as much code as possible in CPAN-style modules (.pm files), with associated unit tests (.t files) for each module.

      The ideal is for commands (.pl files) to be very very short, with almost all automated testing heavy lifting delegated to the module level, leveraging the excellent Perl CPAN module testing tools, such as the prove command. An extreme example of this approach is Perl::Tidy whose perltidy command is essentially just:

      use Perl::Tidy; my $arg_string = undef; exit Perl::Tidy::perltidy( argv => $arg_string );

        I prefer to put as much code as possible in CPAN-style modules (.pm files), with associated unit tests (.t files) for each module.

        Oh!
        That's what those *.t files are for...

        Now I am reading Test::Tutorial which is something else I didn't know existed.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11123946]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-16 12:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found