Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

How to properly use modules?

by tercoz (Acolyte)
on Apr 21, 2012 at 05:33 UTC ( #966306=perlquestion: print w/ replies, xml ) Need Help??
tercoz has asked for the wisdom of the Perl Monks concerning the following question:

I have 4 perl scripts that forms personal area on some website. One does login, another sends e-mail for user to proove his registration, third shows area page, fourth checks data from that page and redirects users to the payment system. Every script has its own subs, and some common subs from the module PersonalArea.pm What if I put all the subs from those 4 scripts into that module, then I shall be able to ease testing of those subs, and may be able to use something like mod_perl in the future is it a good way to flush all the subs into single module? Isn't it a good thing to have all the code in one place ,is it?

Comment on How to properly use modules?
Re: How to properly use modules?
by Happy-the-monk (Monsignor) on Apr 21, 2012 at 06:12 UTC

    Isn't it a good thing to have all the code in one place

    Yes, it actually is a programmer's motto: "don't repeat yourself".

    Cheers, Sören

      Actually no :) DRY says make subroutines/modules, not put it all in one file

      Sure, you could turn four scripts into one module, or you could turn them into four modules, it all depends on how much they share

      Yes repeating is not good, indeed. I just wanted to do some tests with Test::More module and got into a problem, my module is too small and do not cover everything I'd like to test, because most of important subroutines are in the .pl files, how to write tests for those - dunno...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://966306]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2014-10-25 06:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (142 votes), past polls