On 2/20/06, The Ghost <[EMAIL PROTECTED]> wrote:

> I have defined $dbh (a database handle) as a global variable.  I have
> a module, RD, that needs access to the database.  How can I use $dbh
> within the RD module?

Every global variable is in some package, in perl. If you haven't used
a package directive to set a different default package, you'll be in
the main package, and thus that variable's full name is $main::dbh .
You can use that name anywhere in your source, including inside
another module or package, to refer to that same variable.

You may know that many people frown upon the overuse of global
variables, for good reason. Can you coerce your RD module to accept
$dbh as a parameter, perhaps, rather than looking for it as a global?
That's the way most modules work.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to