Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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

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

Replies are listed 'Best First'.
Re^2: Why no bareword warnings while inside of BEGIN (no)
by tye (Sage) 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        

      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?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2016-10-23 00:58 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (299 votes). Check out past polls.