Forum Moderators: coopster & phranque

Message Too Old, No Replies

Debug Information

debug information perl

         

reubensant

5:11 am on Jun 24, 2005 (gmt 0)

10+ Year Member



Hello,

I am a begginner regarding Perl. My problem is that I am running a script which is failing at a particular line. I dont know what's wrong with that line but I am sure that the problem is there, since writing...

print "test";

...before that line returns all the HTML until the word "test", and doing print "test"; after that line, the browser returns all the HTML without "test". In simple words, the script is halting at that line, i.e. the browser just stops recieving HTML at that point.

The line is..
$sql_username = $dbh->quote($values{'username'});

Usually, when I encounter this type of problem I go to SSH and run...

perl myscript.cgi

...and the error (if any) comes up. The problem with my script is that the above line is executed IF I have the POST content set to "mode=register", so when i run my script in the command line, i cannot submit any data from a prevoius form in order to POST mode=register. So, in other words, I dont know how to trigger the above command using command line.

Is there a way to return useful debug information to the browser at that point where the script faces a fatar error just like PHP and ASP?

Btw, no error logs are generated by Apache. The scripts just halts there.

wruppert

3:02 pm on Jun 24, 2005 (gmt 0)

10+ Year Member



Welcome to Webmaster World!

I would guess there is something wrong with your database handle.

You could try (untested):

[pre]
eval {
$sql_username = $dbh->quote($values{'username'});
};

if ($@) {
print "<hr>Error in getting username: <br>",$@, "<hr>";
}
[/pre]

This will trap the error and print the error info.

There is also "use CGI::Carp qw(fatalsToBrowser);" which does pretty much the above automagically.

reubensant

2:32 am on Jun 25, 2005 (gmt 0)

10+ Year Member



Hello, thanks a lot for giving me the following line.

use CGI::Carp qw(fatalsToBrowser);

That's what I needed.