Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'll take this a step further too and mention the diagnostics pragma (perldoc diagnostics). I don't think it is practical for production use, but can be helpful for new Perl folks when learning and finding that their code doesn't seem to work with -w all of a sudden :) The diagnostics pragma will give verbose warning messages (more verbose than the normal -w warnings). Here is an example:

#!/usr/bin/perl -w print "Hello;
When run, this will produce:
Can't find string terminator '"' anywhere before EOF at ./test.pl line 3.

Ok, this is an easy one to see the error :) I am using it for examples sake! Anyways, now, let's change the script to:

#!/usr/bin/perl -w use diagnostics; print "Hello;

Now, this is what you would see:

Can't find string terminator '"' anywhere before EOF at ./test.pl line 4 (#1)

    (F) Perl strings can stretch over multiple lines.  This message means that
    the closing delimiter was omitted.  Because bracketed quotes count nesting
    levels, the following is missing its final parenthesis:

        print q(The character '(' starts a side comment.);

    If you're getting this error from a here-document, you may have
    included unseen whitespace before or after your closing tag. A good
    programmer's editor will have a way to help you find 
these characters.

Uncaught exception from user code:
        Can't find string terminator '"' anywhere before EOF at ./test.pl line 4.

Just an aside to hopefully help some folks learn


In reply to RE: Re: use strict by KM
in thread use strict by Ignorance

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 imbibing at the Monastery: (5)
As of 2024-04-23 21:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found