Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2018-05-21 01:48 GMT
Find Nodes?
    Voting Booth?