Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
according to the message I get when I use the 'use diagnostics' with this code.

Since Sprad was looking for better messages "for warnings like these", I think it's worthwhile to emphasize the use diagnostics pragma Sandy mentioned.

Consider this trivial case:

#!/usr/bin/perl -w my $a = 1; my $c = 2; print $a + c;

Without using diagnostics, I get this:

Unquoted string "c" may clash with future reserved word at test.pl line 5.
Argument "c" isn't numeric in addition (+) at test.pl line 5.

However, if I do use it, I get a much more informative error:

Unquoted string "c" may clash with future reserved word at test.pl line 5 (#1)

    (W reserved) You used a bareword that might someday be claimed as a reserved word.
    It's best to put such a word in quotes, or capitalize it somehow, or insert
    an underbar into it.  You might also declare it as a subroutine.

Argument "c" isn't numeric in addition (+) at test.pl line 5 (#2)

    (W numeric) The indicated string was fed as an argument to an operator that
    expected a numeric value instead.  If you're fortunate the message
    will identify which operator was so unfortunate.

Sure, in the case I've provided it isn't especially helpful, but it can be useful for tracking down more bizarre errors by giving some suggestions.


In reply to Re: Re: Less-than-helpful warnings by jpfarmer
in thread Less-than-helpful warnings by Sprad

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (6)
    As of 2014-12-27 07:08 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (176 votes), past polls