Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

A phantom death

by Rabenschwinge (Novice)
on Dec 18, 2008 at 12:19 UTC ( #731236=perlquestion: print w/ replies, xml ) Need Help??
Rabenschwinge has asked for the wisdom of the Perl Monks concerning the following question:

I have a problem with a phantom "die" statement:

Use of uninitialized value in die at ./correct-<censored>-buch.pl line 114.
Died at ./correct-<censored>-buch.pl line 114.

However, this line does not contain a 'die', even though it used to. Currently it is: $update->execute(($autor, $titel, $verlag, $jahr, $ort, $auflage, $sprache, $einband, $seiten, $format, $stichwort, $sparteName, $lfdnr, $infotext, $preis_euro, $gewicht, $isbn)) or print "Fehler beim Aktualisieren von ISBN $isbn.\n";

I have tried reproducing the problem in a mini script, leaving the parameters for the update uninitialized or using a key for $isbn that does not exist. But not of that failed let alone caused the script to exit by a triggered "die" statement.

'$update' is defined as follows:

#!/usr/bin/env perl use strict; use warnings; use DBD::mysql; (...) my $updateStatement = "UPDATE `<censored>_buch` SET `autor` = ?, `titel` = ?, `verlag` = ?, `jahr` = ?, `ort` = ?, `auflage` = ?, `sprache` = ?, `einband` = ?, `seiten` = ?, `format` = ?, `stichwort` = ?, `sparteName` = ?, `lfdnr` = ?, `infotext` = ?, `preis_euro` = ?, `gewicht` = ? WHERE `isbn` = ? LIMIT 1"; (...) my $db = DBI->connect("DBI:mysql:database=<censored>;host=localhost;po +rt=3306", "<censored>", "<censored>"); my $update = $db->prepare($updateStatement) or die ($DBI::errstr);

Comment on A phantom death
Select or Download Code
Re: A phantom death
by moritz (Cardinal) on Dec 18, 2008 at 12:33 UTC
    You could try to wrap the dying statement in an eval { ... } block, and inspect $db->errstr after that. If it's a DBI error, that might contain some useful information.
Re: A phantom death
by holli (Monsignor) on Dec 18, 2008 at 13:40 UTC
    However, this line does not contain a 'die', even though it used to
    Check if the file you are editing REALLY is the file you are running.


    holli, /regexed monk/
      maybe restart webserver
Re: A phantom death
by derby (Abbot) on Dec 18, 2008 at 15:33 UTC

    Is the RaiseError attribute for your db handle being set somewhere?

    -derby
Re: A phantom death
by shmem (Canon) on Dec 18, 2008 at 18:05 UTC

    To get where the die really occurs, there's Carp, specifically Carp::confess. You can set $SIG{__DIE__} = \&Carp::confess to get a stack trace, though it's not always accurate.

    If this die is occurring inside DBI, a RaiseError =>1 passed to the connect() method should give you useful information.

Re: A phantom death
by jakobi (Pilgrim) on Sep 30, 2009 at 16:05 UTC

    Not yet mentioned: If everything fails, there's always the lowlevel approach of using the perl -d, type s<CR>, then keep <CR> pressed: this should give you the the last few lines of code before it dies, and thus an idea what actually happens. Maybe with a suitable breakpoint to speedup reaching the problematic line. man perlrun, man perldebug. Printing the arguments of the dying function call might also help -> perldoc -m Data::Dumper once again.

    Meta: shouldn't there be an existing help/faq node on basic debugging; or do we assume this to be well-known?

      Meta: shouldn't there be an existing help/faq node on basic debugging; or do we assume this to be well-known?

      Well, Tutorials has a section Debugging and Optimization, but it doesn't have many articles. More would be appreciated!

      I've updated the Tutorials Quest with this request.

      Between the mind which plans and the hands which build, there must be a mediator... and this mediator must be the heart.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://731236]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-09-01 12:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (8 votes), past polls