Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Why no bareword warnings while inside of BEGIN

by Limbic~Region (Chancellor)
on Mar 22, 2004 at 22:57 UTC ( #338813=note: print w/ replies, xml ) Need Help??


in reply to Why no bareword warnings while inside of BEGIN

JayBonci,
If you want to see it blow up you will have to do:

BEGIN { while( calldepth < 5 ) { last; } }
From perldoc perlmod
A BEGIN subroutine is executed as soon as possible, that is, the moment it is completely defined, even before the rest of the containing file is parsed.

You have put it into an infinite loop - never giving it a chance to throw the error.

Cheers - L~R


Comment on Re: Why no bareword warnings while inside of BEGIN
Download Code
Re^2: Why no bareword warnings while inside of BEGIN (no)
by tye (Cardinal) on Mar 22, 2004 at 23:25 UTC

    The BEGIN block *can't* be run until the block is finished being compiled. If the block is finished being compiled, it is reasonable to expect that barewords would have been detected. As I show elsewhere, other types of 'strict' errors are handled correctly here.

    So I don't see how your reading of the documentation explains this problem away. The quoted section says that it runs before the "rest of the containing file is parsed". The error is in the code being run. It certainly can and should report fatal errors in that code before it runs it.

    - tye        

      tye,
      So this is a bug/feature, I see it in your reply below.
      I thought:

      Because a BEGIN block executes immediately,...

      Meant that it executed and then execeptions were thrown. After running it through perl -MO=Deparse, I thought it was expected behavior since it doesn't seem to matter what kind of loop it is - the error isn't thrown until after it is completed.

      Cheers - L~R

      Update: Changed bug/feature to statement rather than question after seeing tye's reply further down in thread

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://338813]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2014-08-22 21:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (165 votes), past polls