Re: perl


Subject: Re: perl
From: Arthur Corliss (arthur@corlissfamily.org)
Date: Sun Apr 14 2002 - 17:28:44 AKDT


> I've got a question for perl people.
>
> Inside a script I want to refer to another script (and have the variables
> carry over). I want to have a separate script that has all my database
> connection info, so I can refer to this script whenever connecting
> to a particular database. I've got the Learning Perl book, but it doesn't
> explain how I would do this. Any hints would be helpful. Thanks.

There's several ways to skin this cat. You could either define command-line
arguments that are parsed by the child script to get the settings it needs,
or you could use eval to execute the script's code in the lexical context of
the parent program. Please be aware, though, this can be dangerous since
variable settings, subroutines, etc., will remain after the script is
executed. You really need to do some careful management of internal
namespace to avoid problems.

That said, I would recommend that you move your code to be used in a more
modular manner, with whatever objects/interfaces needed being loaded upon
demand. Same effect, much safer method of execution.

--

--Arthur Corliss Bolverk's Lair -- http://arthur.corlissfamily.org/ Digital Mages -- http://www.digitalmages.com/ "Live Free or Die, the Only Way to Live" -- NH State Motto

--------- To unsubscribe, send email to <aklug-request@aklug.org> with 'unsubscribe' in the message body.



This archive was generated by hypermail 2a23 : Mon Apr 15 2002 - 11:24:23 AKDT