Link to home
Start Free TrialLog in
Avatar of Stanley Lai
Stanley LaiFlag for Hong Kong

asked on

How to debug the perl via cgi?

I am calling perl program from a web. When there is a problem, the error returns page cannot be displayed.
How i can generate meaning error and see for debug?
SOLUTION
Avatar of Kim Ryan
Kim Ryan
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of manav_mathur
manav_mathur

...or you can check your webserver error logs to see the details.
Avatar of FishMonger
use warnings;
use diagnostics;
use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;


warningsToBrowser(1);   # this goes after you print the header
You might also try calling the program from the command line using the same parameters that cause the error, so you can use the Perl source debugger.
Avatar of Stanley Lai

ASKER


teraplane solution is perfect.

FishMonger, i got errors simply using use warnings. not sure why.
use diagnostics my perl cannot reconize.
if you're not sure why you get warnings, that could indicate a problem.
You should determine he cause of the warnings and try to eliminate them.
If you don't understand the error messages, post them here along with the code,
and we may be able to help you interpret them.

use CGI::Carp 'fatalsToBrowser'
this seems could capture the syntax error for me.
However, if there is run time error, it cannot give me clue.

e.g. i have database call with incorrect sql. It just gives me the page not found.
<offtopic>
Does the runtime error occur everytime, or for selected user-inputted values??
If the answer to the above is "selected values", you should be putting a lot of checks to first make sure that the database call you are making is valid. Putting user-supplied fields straight into your sql makes your code prone to sql injection attacks.

If the error occur always, follow the advice given in http:#14024929
</offtopic>

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Hi lovesnakeyjakey , it works! so great!
In my case, i cannot use -T, i dont know why. But without -T still work. What does -T means?

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial