Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How to Debug my perl script? (updated)

by haukex (Archbishop)
on Sep 28, 2016 at 10:55 UTC ( [id://1172828]=note: print w/replies, xml ) Need Help??


in reply to How to Debug my perl script?

Hi ankit.tayal560,

Please see the Basic debugging checklist - particularly item Nr. 3 on that list (unexpected whitespace) will solve your problem.

I'd also suggest you limit the scope of your my declarations, don't declare them until the scope where you need them. In particular, look at @attributes: It can be declared just before if ( $sig->getElementsByTagName("attributes") ). In this case it's not a problem, but if you were to place that chunk of code into a loop, @attributes would not get cleared. Only declaring your lexical (my) variables until the scope where they are needed is a very good habit to get into.

Update: Another important debugging technique is reducing your code to as little as necessary to reproduce the problem. This helps you in narrowing down where the problem is occurring, and it helps us in having less code to wade through. See also Short, Self Contained, Correct (Compatible) Example.

Also: Don't turn off warnings, they can be very useful!

Hope this helps,
-- Hauke D

Replies are listed 'Best First'.
Re^2: How to Debug my perl script? (updated)
by ankit.tayal560 (Beadle) on Sep 28, 2016 at 11:18 UTC

    worked! thanks a lot

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1172828]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-03-28 16:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found