Re: perl


Subject: Re: perl
From: Arthur Corliss (arthur@corlissfamily.org)
Date: Tue Apr 16 2002 - 20:34:58 AKDT


On Tue, 16 Apr 2002, Chris Hamilton wrote:

>
> Thanks, sounds like I need to learn about modules. Here is what I am trying
> to do... I want to have a script/module that contains all of my database
> connection parameters and will make these parameters available to the
> calling script.
>
> Here are the connection parameters that I want to include in a separate
> script/module:
>
> my $serverName = "localhost";
> my $serverPort = "3306";
> my $serverUser = "johndoe";
> my $serverPass = "slick";
> my $serverDb = "DBName";
> my $serverTabl = "TableName";
>
> That's it. When I use "require" to try and include a script containing the
> info above, I get nothing (no errors or anything, just the html stuff).
> When I use require to make "Hello world" print in the browser it works. Is
> there something special about passing variables that I should know about. I
> bought a perl for dummies book today. So hopefully my days of being a dummy
> are numbered. I saw Arthurs book there too, but figured I would get lost
> just reading the Acknowledgments.

Keep in mind, just requiring it only loads and (demi)compiles the code.
You'll need to call one of the subroutines in order to start execution. Which
is why you may want to consider loading the text of the required file into a
scalar and eval'ing it, instead. That'll cause normal execution of the code
body, should you need to work it that way.

        --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 : Tue Apr 16 2002 - 21:30:28 AKDT