G'day m_alper_yildiz,

Welcome to the monastery.

I note in a number of the replies here, use of the diagnostics pragma is suggested. Instead of editing and rerunning your code, you can look up the verbose diagnostic messages in perldiag.

There are a very large number of messages in perldiag so you'll probably need to search for the one you want. Be aware that variable parts of the message (e.g. the "some variable" in your post) are usually shown as "%s"; accordingly, just search for a significant, non-variable part (e.g. 'requires explicit package name' finds 'Global symbol "%s" requires explicit package name' but '"$x" requires explicit package name' finds no matches).

Alternatively, you can feed the entire, unedited message to splain (see perldiag - The splain Program). Here's an example:

$ splain /Users/ken/perl5/perlbrew/perls/perl-5.18.0t/bin/splain: Reading from +STDIN Global symbol "$x" requires explicit package name Global symbol "$x" requires explicit package name (#1) (F) You've said "use strict" or "use strict vars", which indicates + that all variables must either be lexically scoped (using "my" or +"state"), declared beforehand using "our", or explicitly qualified to say which package the global variable is in (using "::"). ^C

While you are learning Perl, the diagnostics pragma can be useful; however, it is generally not a good idea to retain it in production code. Here's a non-exhaustive list of reasons why not to use this pragma in production code:

-- Ken


In reply to Re: Explicit package name Warning!!! by kcott
in thread Explicit package name Warning!!! by m_alper_yildiz

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.