> I tried using > $self->dbh($dbh); <- Didn't work for me > $self->query('dbh',$dbh) <- Also didn't work for me
Did you try: $self->param("dbh", $dbh); ? > our $dbh= etc. < -- Works, but is this the right way? Yes, it is ok. But it creates a global variable, if that's what you wanted. Also, not available in older perl (older then 5.6) > > What is the recommended way of doing this? > > > > sub setup { > my $self = shift; > $self->start_mode('mode1'); > $self->mode_param('rm'); > $self->run_modes( > "AUTOLOAD" => 'show_main', > 'mode1' => 'show_main', > ); > > $self->tmpl_path('/usr/local/apache/saint_tmpl/'); > > # Connect to DBI database > > my $database = "saint"; > my $hostname = "localhost"; > my $driver = "mysql"; > my $dsn = "DBI:$driver:database=$database;host=$hostname"; > > our $dbh = DBI->connect($dsn,"user","pass", {'RaiseError'=>1} ) > or die "Couldn't connect to database: " . DBI->errstr; > > # $self->dbh($dbh); > } > > > sub show_main { > my $self = shift; > > # Get CGI query object > my $q = $self->query(); > > my $cookie = $q->cookie(COOKIE); > our ($dbh); # <---------- HERE > > etc. > > } > > --------------------------------------------------------------------- > Web Archive: http://www.mail-archive.com/cgiapp@lists.vm.com/ > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/cgiapp@lists.vm.com/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]