[ale] Perl Question

michael d. ivey ivey at gweezlebur.com
Tue Mar 2 09:44:11 EST 2004


On Tue, Mar 02, 2004 at 09:25:47AM -0500, Chris Fowler wrote:
> I have many perl programs that have common code.  I want to somehow
> include a perl program that defines functions for this code.  What is
> the best way?
> 
> I also want to store variables in a central file and source them like I
> can in bash.  I can not find the perl equivalent.  How can I do that?

The preferred way would be to write a module (man perltoot) and have all
of your common code in that.  Then your programs would
use MyModule;

Alternatively, just stick the common code in a file and
require '/full/path/to/file.pl';

That covers both questions, unless the first one was "I want to write a
program that outputs perl code, and include that in my other program" in
which case you want a combination of eval, backticks, and require.  Or a
temp file.  But I don't think that's what you meant, anyway.

-- 
michael d. ivey        [McQ] : "The power of accurate observation is
   <ivey at gweezlebur.com>     : commonly called cynicism by those who
http://gweezlebur.com/~ivey/ : have not got it."
 encrypted email preferred   :                   -- George Bernard Shaw



More information about the Ale mailing list