Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Splitting a project into smaller files

by chacham (Prior)
on Nov 14, 2011 at 23:43 UTC ( [id://938048]=perlquestion: print w/replies, xml ) Need Help??

chacham has asked for the wisdom of the Perl Monks concerning the following question:

I am starting a project which i would like to split into different files for manageability. I am under the impression that files are not simply included, and modules are created and included. If so, i would like to keep all of the files in the same directory.

This is new to me, and i have a few questions.

  1. Is it preferable or to split up files, or does it make no difference?
  2. Is the preferable way to split via modules?
  3. Where are the modules kept?
  4. Do the modules need to be compiled?
  5. Is there a naming scheme for project/related files?

I was searching for these things online, but the words split brings up help about modules that split, and local directory modules bring up how to Make a module. Is there a good name to use for splitting up a perl project into smaller parts?

Replies are listed 'Best First'.
Re: Splitting a project into smaller files
by GrandFather (Saint) on Nov 15, 2011 at 01:26 UTC

    For a start see Including files in the Tutorials section.

    In general use modules to organise code into libraries (collections of related code). One reason to put code into modules is so that you can write test suites that focus on the interfaces provided by the modules. That allows you to develop module code independently of the client code with some assurance that you haven't broken the client code that depends on it - if the tests still pass the client code ought be happy with the module changes you've made.

    Pretty much the answers to all your numbered questions fall out of considering why and how you want to organise the code into modules (except 4, to which the answer is 'No' and maybe 2, to which the answer is 'Yes').

    True laziness is hard work
      Thank you. That tutorial gave me a good start.
Re: Splitting a project into smaller files
by JavaFan (Canon) on Nov 15, 2011 at 00:27 UTC
    Is it preferable or to split up files, or does it make no difference?
    That depends on many factors; with preferences of the authors not the least of them. Since it's your project, the most important question to ask is "do I prefer many files, or a larger single one?".
    Is the preferable way to split via modules?
    It's the common way. Whether that's preferably for your project? Who knows. Tell us.
    Where are the modules kept?
    Not sure what kind of answer you are looking for. Files? Disks? Storage arrays?
    Do the modules need to be compiled?
    No.
    Is there a naming scheme for project/related files?
    There will be if you make one. If you decide not to, there will not be one.
Re: Splitting a project into smaller files
by Anonymous Monk on Nov 15, 2011 at 01:38 UTC
Re: Splitting a project into smaller files
by davido (Cardinal) on Nov 15, 2011 at 16:00 UTC

    ...and no list of resources on how to deal with modules would be complete without Intermediate Perl (O'Reilly).

    It addresses all of the questions in the OP, and more.


    Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (9)
As of 2024-04-19 06:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found