Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Why no bareword warnings while inside of BEGIN

by ChemBoy (Priest)
on Mar 22, 2004 at 22:54 UTC ( #338810=note: print w/ replies, xml ) Need Help??


in reply to Why no bareword warnings while inside of BEGIN

I don't know the answer, but I suspect it has to do with the "run-as-soon-as-possible" nature of BEGIN blocks. One reason I suspect this is that if you change calldepth < 5 to calldepth > 5, you get a bareword error. Also, you get a bareword error (or at least, I do) if you run a similar one-liner:

perl -e 'use strict;BEGIN{if (bareword > 1) {1} }'
which probably makes the answer obvious to some people, though it doesn't to me. :-)



If God had meant us to fly, he would *never* have given us the railroads.
    --Michael Flanders


Comment on Re: Why no bareword warnings while inside of BEGIN
Download Code
Re: Re: Why no bareword warnings while inside of BEGIN
by JayBonci (Curate) on Mar 22, 2004 at 22:59 UTC
    Okay, so a pared down example of why this is kinda scarry is this:
    perl -e "use strict; BEGIN { while(bareword < 1) {1} }"
    Cycles forever. No error
    perl -e "use strict; BEGIN { while(bareword > 1) {1} }"
    Throws the bareword error ...wierd. --jay


        --jaybonci
      JayBonci,
      See my post below. The while loop is infinite because 0 < 1. It never enters the loop when 0 > 1. Not throwing the error until after the code is run may or may not be expected behavior as tye points out.

      Cheers - L~R

Log In?
Username:
Password:

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

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

    How do you remember the number of days in each month?











    Results (198 votes), past polls