Click to See Complete Forum and Search --> : How to access variables from another module


helpcomm
09-04-2008, 11:16 AM
Hi,

I am new to perl and i want to debug a perl program.

I have the following statement:
$dbh=DBI->connect("DBI:mysql:$DBNAME",$DBUSER,$DBPASS)

And i want to display the content of DBI:mysql:$DBNAME so that i know what is the name of the database.

i did : print DBI:mysql:$DBNAME;

But it does not work!

Thank you

Nedals
09-04-2008, 07:42 PM
Am I missing something?

print $DBNAME;

Sixtease
09-05-2008, 02:31 AM
Just to clear things a bit, DBI:mysql:$DBNAME is not variable $DBNAME in the module DBI:mysql. This syntax is specific to DBI and it simply encodes three things in one parameter.

If you really had a DBI::mysql module (notice the double colon), and a $DBNAME variable in it, you'd spell it like this:
$DBI::mysql::DBNAME
Notice the sigil before the package name and double colons as separators.