PDA

View Full Version : Perl equivalent of bash "source"?


Feztaa
03-07-2002, 02:40 AM
Hello,

I'm working on a perl script (it generates the static content of my website), and it's getting very large.

I was just wondering if there was some way I could split it up into different files, and then "source" those files into the main script so that it still works?

For example, the project I'm working on is object oriented, and I'd like to have the package definition in one file, and the actual object creation and manipulation in another file.

I know I could split off the package into it's own file, and put it in /usr/lib/perl5/5.6.1, then use the 'use' command to use that package, but I'd prefer to keep all the files in one directory if possible.

Thanks ;)

EscapeCharacter
03-07-2002, 02:49 AM
require("filename.pl") works just fine for me give it a try

Feztaa
03-07-2002, 07:32 PM
D'oh! I can't believe I forgot that ;)

Thanks.

slade
03-08-2002, 12:22 PM
You don't have to keep the .pm files in another directory, you can modify the one that Perl uses to load the files from. The array is called @INC and you can add your directory to it so Perl will search there for the modules as well.

-Vic

Feztaa
03-12-2002, 07:14 PM
This is what I came up with (not quite production quality, but it works for me):

http://members.shaw.ca/feztaa/genpage.pl
http://members.shaw.ca/feztaa/defobj.pl