in reply to splitting a source file

No offense to the 'write a module' folks, but we are talking about a beginner here with a program that's under 1k lines. What's wrong with some simplicity? kd, put your subs into as many files as you want and include them require
#!/bin/perl require "bunch_o_subs.pl"; ...
If you want to get a bit more advanced, you can go with Modules and there are certainly many advantages to them, but if you are just looking to clear the clutter up a bit and segregate the subs out, there is nothing wrong with using require.

Replies are listed 'Best First'.
Re^2: splitting a source file
by chromatic (Archbishop) on Oct 24, 2007 at 19:58 UTC
    What's wrong with some simplicity?

    Provided all you ever want to do is stuff some subroutines someplace and use them later, not much... but you give up namespaces, compile-time bindings, custom import, path management, and a few other features. You have to go through hoops to create your own classes. You don't learn how to use other modules..

      Just because someone uses a require doesn't mean that they forfeit the user of other modules. I used modules for years before writing my own.

      And for small apps, Namespaces isn't really a large factor.

      It's easy to over-engineer applications. Many times, someone just wants to write a bit of code that does the trick on a single machine where they are the user, the developer and the maintainer. Under these circumstances, I don't see why someone who is relatively new to perl should jump into creating modules and worrying about namespaces.

      Having said that, I will concede that there is never a better alternative to good coding standards and procedures. But if you really want to get there, it can happen a bit more organically. As soon as he runs into a namespace issue he'll be looking into modules. Let it wait until then. Right now, he needs to clean up the clutter a bit.
        Right - one step at a time; just getting results with a minimum of effort can preserve momentum.

        It took me years before I "needed" modules.

        At the same time, it's good to know they're out there, even if you're not going to use them.
      It's his first time, let him start with require. It'll do for now.

      Later, in a next project, or in a rewrite, he can add use, packages and all the rest... But use is just an extension of require. Let him start simple.