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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

This is a matter of simple debugging: Read the error message, look at the line in question, discover what variables are involved, put some warn statements here and there at places in your code where you believe the variables involved are being set or tested -- the warn statements should print the value of those variables, run your code, verify your assumptions.

If the warning message seems cryptic, add "use diagnostics;" to the top of your script, and the warning will be explained to you in greater detail.

Here's a trivial example of the "print statements" (or warn) style of debugging:

my $counter = 0; warn "\$counter initialized to <<$counter>>\n"; while( $counter != 10 ) { warn "Entering while block. \$counter is <<$counter>>\n"; $counter++; warn "End of while block. \$counter is <<$counter>>\n"; } warn "Loop terminated. \$counter is <<$counter>>\n";

This sort of drudgery may seem tedious. You could, alternatively, read perldebtut to learn how to use the Perl debugger. But for now, warn is all you need to discover where you're going wrong.

You really don't need us to follow those steps for you. You need to learn how to do them yourself so that you don't need to rely on PerlMonks every time a surprise comes your way. Learning debugging techniques is an essential part of the practice of programming.


In reply to Re: Set operations by davido
in thread Set operations by Panfi96

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2021-06-15 00:46 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (66 votes). Check out past polls.