When I run the program, I keep getting "syntax error near 'print'".

Perl error messages generally report the line number in your script where the error occurred. (If you didn't see a line number in the error message, this would be evidence in favor of what others concluded -- maybe this isn't an error message from perl.)

Did you confirm that the line number in the error message matches the line number that you've shown us?

For future reference, when posting a question like this, it is best to paste in the exact text of the error message, and to show not only that particular line of your code, but also at least a few lines around it.

When variables or objects are used in the line causing the error, it also helps to say a little bit (or show additional code) to clarify what values (if any) have been assigned to the variables.


In reply to Re: Syntax error near Print by graff
in thread Syntax error near Print by ITmajor

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.