Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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 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?

Replies are listed 'Best First'.
Re: How to properly use modules?
by Happy-the-monk (Canon) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://966306]
Approved by davido
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2018-06-21 22:21 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (120 votes). Check out past polls.