http://www.perlmonks.org?node_id=966306

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?

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