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?? |
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,
In Section
Seekers of Perl Wisdom
|
|