I have come to the conclusion that passing perl parameters from one perl 
subroutine to another just doesn't work in CGI.  It looks like everything 
is passed by value, and the language is not set up to take refs.  This 
being the case, how best to handle the following piece of DBI code:
my    $dbh = DBI:connect($connectionString);   # connect to the database
my    $sth = $dbh->prepare($cmd);   # prepare a command 

What I think that I have found is that

my $dbh = DBI:connect($connectionString)  # dbh is a global variable set 
in a global context

..

sub fubar{
      my $sth = $dbh->prepare($cmd);
}
seems to work, but it does not work to have the global variable set inside 
a subroutine and accessed from another.  If it were a character string, I 
would use hidden() to pass the values from one subroutine to another, but 
the cgi macros are not set up to handle ref variables!

If I am right, that I can set $dbh globally and access it from some 
subroutine, can I do this

if (something is true) {

    my   $dbh = DBI:connect($connectionString);
}

sub fubar{
    my $sth = $dbh->prepare($cmd)

I've been wrestling with this problem for several hours, now, and would 
appreciate hearing from someone who knows more about this!

Thanks.
Mary Anderson

-- 
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