CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Frequently Asked Questions:
How do I debug my Perl programs?

 



Jasmine
Administrator

Jan 19, 2001, 11:50 AM

Post #1 of 1 (2058 views)
How do I debug my Perl programs? Can't Post

(From the Perl FAQ)

How do I debug my Perl programs?

Have you used -w? It enables warnings for dubious practices.

Have you tried use strict? It prevents you from using symbolic references, makes you predeclare any subroutines that you call as bare words, and (probably most importantly) forces you to predeclare your variables with my or use vars.

Did you check the returns of each and every system call? The operating system (and thus Perl) tells you whether they worked or not, and if not why.

Code
  open(FH, "> /etc/cantwrite") 
or die "Couldn't write to /etc/cantwrite: $!\n";

Did you read the perltrap manpage? It's full of gotchas for old and new Perl programmers, and even has sections for those of you who are upgrading from languages like awk and C.

Have you tried the Perl debugger, described in the perldebug manpage? You can step through your program and see what it's doing and thus work out why what it's doing isn't what it should be doing.



 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives