Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Presumably you've gotten it all working now. But I just wanted to mention something that I hope will aid you as you start into learning to program.

Always look at the error messages you're getting. Always start with the first one and figure out why you're getting it. After you've fixed it, move on to the next.

In the case of your code, first you'll get a syntax error on line seven, because there's no code block following the while(0) syntax.

The next syntax error will be your final for loop, which isn't terminated with a closing brace.

Your final foreach loop works as a statement modifier, so the comma between the "\n" and the foreach is unnecessary, and confusing.

If you get in the habit of looking at the error messages with an attitude of, "I should figure out what this is telling me, and why.", you'll find your emerging adventure in programming more fun.


Dave


In reply to Re: Perl Loops by davido
in thread Perl Loops by stamp1982

Title:
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 How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-16 23:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found