Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Getting the error message:
Can't call method FETCH on an undefined value at D:/Perl/site/lib/Win32/TieRegistry.pm line 1486 during global destruction.
Here is what is the part under suspicion:
print LOGFILE "$SQL_login"; # $cursor_login = $dbh_login->prepare($SQL_login) # || die "Couldn't prepare statement: " . $dbh_login->errstr; print LOGFILE " made it $cursor_login"; #$cursor_login->execute; #@fields_login = $cursor_login->fetchrow; $validid_login = $fields_login[0]; print LOGFILE " element is $validid_login"; $firsttime_login = $fields_login[1]; print LOGFILE " element is $firsttime_login"; #$cursor_login->finish; #Close the database $dbh_login->disconnect;
Here's the whole code:
#!c:/perl/bin -w BEGIN { push (@INC, "c:/progra~1/unwire~1/UPSDKH32/examples/apputils") +; } open (LOGFILE, ">/logs/reclaim.log"); # Load required application utilities require 'HDMLUtils.pl'; #use vars qw{$SPLASHSCREEN_login}; $SPLASHSCREEN_login = '<HDML VERSION=3.0 MARKABLE=TRUE TTL="0"> <ACTION TYPE=ACCEPT LABEL=OK TASK=GO DEST="?NEXT=LOGIN"> <DISPLAY TITLE="Mobile Media Portal"> <CENTER>%s %s %s </DISPLAY> </HDML>'; #Call the main function to begin execution &Main; ###################################################################### +###### # # Subroutine Name: Main # # Purpose: Parse the CGI variables into the cgiVars hash and cotrols # component navigation based on $nextState # ###################################################################### +###### sub Main { $subid_login=$ENV{'HTTP_X_UP_SUBNO'}; my ($dbh_login, $SQL_login, $cursor_login, @fields_login, $validid_lo +gin, $firsttime_login); # This Tells PERL to use the Database Interface use DBI; # Establish DataBase handle $dbh_login = DBI->connect("dbi:Oracle:tyson", "scott","tiger", {PrintError => 0}) || die $DBI::errstr; # $dbh_login = DBI->connect("dbi:Oracle:kcmmp", "widl","widl", # {PrintError => 0})|| die $DBI::errstr; # Setup STATIC query string $SQL_login = "select SUBSCRIBERID, FIRSTTIME from CTIA_SUBSCRIBERID where SUBSCRIBERID = '$subid_login'"; print LOGFILE "$SQL_login"; # $cursor_login = $dbh_login->prepare($SQL_login) # || die "Couldn't prepare statement: " . $dbh_login->errstr; print LOGFILE " made it $cursor_login"; #$cursor_login->execute; #@fields_login = $cursor_login->fetchrow; $validid_login = $fields_login[0]; print LOGFILE " element is $validid_login"; $firsttime_login = $fields_login[1]; print LOGFILE " element is $firsttime_login"; #$cursor_login->finish; #Close the database $dbh_login->disconnect; &AppUtils::OutputDeck(sprintf($SPLASHSCREEN_login, "Made it here", $validid_login)); #$subid_login, $firsttime_login }
Thanks in advance you rule.

Replies are listed 'Best First'.
Re: Basic-- Error
by chadh (Novice) on Jan 26, 2001 at 06:49 UTC

    It's not clear how Win32::TieRegistry is coming into the picture here. Is that something the Unwired Planet Perl SDK uses?

    Most of your DBI code is commented out, though -- you're basically just creating a connection, printing some log entries, and disconnecting. $validid_login is going to be undefined: perhaps AppUtils::OutputDeck has issues with that.

Re: Basic-- Error
by tye (Sage) on Jan 26, 2001 at 06:32 UTC

    Sorry, my fault. I'll add the fix here in a bit.

            - tye (but my friends call me "Tye")

      Download (from CPAN) and install the latest version (0.24) of Win32::TieRegistry to eliminate the spurious error. Installing the module only involves put a single *.pm file in place so it isn't much work to install the new version in your own directory if you can't get the site to update the module.

              - tye (but my friends call me "Tye")
Re: Basic-- Error
by sierrathedog04 (Hermit) on Jan 27, 2001 at 02:25 UTC
    Is there some reason that you are not saying "use strict;" at the top of your program? "use strict;" forces you to declare your variables before you use them and hence catches typos in your variable names. It is even possible that the UNDEFINED error you are getting is the result of a typo.

    "use strict;" tells you what line the typo appears on. I have heard it said that one should always place "use strict;" at the top of one's programs.

    Yes, it can be a pain to declare variables first, but it is always worth it in the long run. As my idol Nature Boy Flair used to say:

    Learn to like it, learn to live with it, learn to love it, because it is going to be that way for a long time. Whooo!