in reply to Subroutines loaded in from other files

While I would recommend bundling more than one related subroutine in each file for easier bookkeeping, here is a simple way:

Make a file named Module.pm in '/usr/home/you/modules'. This one should contain something like:

package Module; require Exporter; @ISA = Exporter; @EXPORT = qw(dostuff); sub dostuff { my ($dostuff) = @_; return $dostuff } 1; __END__
One of those for each subroutine. Obviously you must substitute your own names and code. That 1; at the end is required!

You then call them by adding:

use lib '/usr/home/you/modules'; use Module qw(dostuff);

to your main program.

I disagree with using a 'main' subroutine. It is un-Perlish and serves no purpose.

--
Regards,
Helgi Briem
helgi AT decode DOT is

Replies are listed 'Best First'.
Re: Re: Subroutines loaded in from ohter files
by gjb (Vicar) on Nov 28, 2002 at 16:19 UTC

    I'm not using a main function either, but consider doing so in the future since it may help trap scoping errors and eliminates global variables which is always a Good Thing(tm).

    Just my 2 cents, -gjb-