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


In reply to Re: How to Debug my perl script? (updated) by haukex
in thread How to Debug my perl script? by ankit.tayal560

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.