lagrenouille has asked for the wisdom of the Perl Monks concerning the following question:
I'd like to be able to have $current_vote and the other variables worked out in the library file and then I can just use them in the other scripts as this is common to all of them.## Read the current vote number from the mySQL database. my $dbh = DBI->connect("DBI:mysql:$database","$username","$passwor +d") || error_fatal ("[ vote.cgi: Admin: Unable to open mySQL database + - $! ]"); my $sth_1 = $dbh->prepare("SELECT current_vote FROM vote_count;"); $sth_1->execute(); my @vote_no = $sth_1->fetchrow_array(); my $current_vote = $vote_no[0];
How do I use pointers to access these variables from the library file in the main script? (using strict)sub return_variables { my $server_root = "/var/www/"; ## MySQL database configuration. my $database = "mercury:localhost"; my $username = "mercurus"; my $password = "mercurus"; my @variables = ("$server_root","$db_database","$db_username", +"$db_password"); return @variables; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Includes, strict and pointers.
by jarich (Curate) on Sep 23, 2002 at 05:37 UTC | |
by joe++ (Friar) on Sep 23, 2002 at 09:04 UTC | |
by lagrenouille (Acolyte) on Sep 23, 2002 at 06:36 UTC | |
|
Re: Includes, strict and pointers.
by blakem (Monsignor) on Sep 23, 2002 at 05:41 UTC | |
|
Re: Includes, strict and pointers.
by graff (Chancellor) on Sep 23, 2002 at 06:24 UTC | |
|
Re: Includes, strict and pointers.
by krisahoch (Deacon) on Sep 23, 2002 at 12:18 UTC |