Script debugger
IS there anywhere on the net that will help debug a perl script? IE, telling you what the errors are (or roughly what they are) and where they are etc. I really could do with one.
Also, I had Activestate perl on before I formatted my hdd and whenever I ran any script with a call to open a file it always seemed to mess up. IE, it didnt show any errors or anything, even when ion the net it did mess up. Does it always do this?
Cheers
richjb posted this at 01:52 — 13th July 2000.
They have: 193 posts
Joined: Feb 2000
There are quite a few things you can do to check your code.
Example:
#!/usr/bin/perl -w
BEGIN {
use CGI::Carp qw(fatalsToBrowser);
}
Hope that helped.
Richard
[email protected]
Everyone here has a website. It's just that not all are worth posting (Mine! ).
richjb posted this at 01:55 — 13th July 2000.
They have: 193 posts
Joined: Feb 2000
Add a die command to the end of your open calls, that way you know if it is failing.
Example:
$file = "/this/is/a/file.txt";
open(FILE,"<$file") || die "Cannot open file $file. Reasons: $!";
close(FILE);
The above code will print what is in quotations if the open call does not work. It will also exit the script.
Richard
[email protected]
Everyone here has a website. It's just that not all are worth posting (Mine! ).
minton posted this at 06:42 — 13th July 2000.
They have: 314 posts
Joined: Nov 1999
Thanks for your hepl richard, the fatals to browser should be very useful
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.