Hey there, here's a question for the class. Why don't you get bareword warnings under "use strict" while you're in a BEGIN {} block. Here's some code:
#!/usr/bin/perl
use strict;
#use warnings;
#require strict;
sub BEGIN {
#while(calldepth < 5)
{
}
#$strict_error_here =1;
};
sub foo {
#while(calldepth < 5)
{
}
}
#while(calldepth < 5)
{
}
Some notes about the following code:
- Uncommenting the while() inside of BEGIN throws no warning. Doing so with use warnings in effect gives a non-numeric warning, but still allows the code to loop forever.
- Uncommenting the while in the subroutine foo() and by itself, both produce the warning under strict;
- Placing a use strict; doesn't do anything inside of BEGIN
- Uncommenting $strict_error_here actually causes a parse error
- Switching the calldepth to something like calldepth++, also produces the error.
So I guess my question is, why doesn't a bareword throw an error inside of a BEGIN function (under strict)?
My second question is, is there any reason at all for perl to not warn you when comparing against a constant in a while() or unless() function, as in the functions above.
Any insight into perl's murkiness here would be great
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.