Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

It appears that the test for barewords happens after compiling is finished. The test for undeclared variables also appears to wait until compilation is finished but happens sooner:

> perl -w use strict; BEGIN { while( calldepth < 5 ) { sleep 1; } print $n; } Global symbol "$n" requires explicit package name at - line 6. BEGIN not safe after errors--compilation aborted at - line 7.

Note that I don't even have to type end-of-file there but that the error didn't appear until I finished the BEGIN block. If the infinite loop ever finished, then you'd get the 'bareword' error:

> perl -w use strict; BEGIN { my $n= 5; while( calldepth < $n ) { warn $n--; } } Argument "calldepth" isn't numeric in numeric lt (<) at - line 4. 5 at - line 5. 4 at - line 5. 3 at - line 5. 2 at - line 5. 1 at - line 5. my $x = 5; BEGIN { warn "interesting" } Bareword "calldepth" not allowed while "strict subs" in use at - line +4. BEGIN not safe after errors--compilation aborted at - line 12.

Note that I still didn't have to type end-of-file. And it didn't take until the file was finished being compiled. So it seems like this might be a problem that can be fixed. The BEGIN block can't be run until it is done being compiled. The check for barewords is happening after the block is done being compiled but after the block is run.

So the next step is to figure out why it waits (until a subsequent BEGIN block is declared, in the above example) before the check for barewords is done?

Updated.

- tye        


In reply to Re: Why no bareword warnings while inside of BEGIN (more) by tye
in thread Why no bareword warnings while inside of BEGIN by JayBonci

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 pondering the Monastery: (5)
    As of 2014-07-28 05:50 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (187 votes), past polls