Beware of that BEGIN, END, CHECK, INIT, AUTOLOAD, and DESTROY can have a sub keyword in front of them. They can also be prototyped. AUTOLOAD and DESTROY are not relevant for this post though.
However, CHECK and INIT are relevant! Try this one-liner: perl -wle'BEGIN { require "browserUk.pl" }' where browserUk.pl is your program above, but with __END__ changed to __DATA__ (why did you use __END__ over __DATA__ anyway?), some code in DATA changed, and with a true return value:
Another issue would be to take care of use() statements as they're compile-time statements. But if you get rid of use statements, then you might also create compilation errors, since the use() statement might import prototyped subroutines. For instance, perhaps a &cool subroutine prototyped with () was imported in the code above.use strict; while(<DATA>) { chomp; my $code = $_; tr/\n//d; s[((?:BEGIN|END)\s*{)][sub syntax_check_$1]g; eval 'return;' . $_; print "'$code' \n\t: ", $@ ? "Fails with\n$@" : 'Passes syntax che +ck'; } 1; __DATA__ INIT { print '*** GOTCHA!!! ***'; } # Executes. CHECK { print '*** GOTCHA!!! ***'; } # Executes. sub BEGIN { print '*** GOTCHA!!! ***'; } # Fails to compile. END () { print '*** GOTCHA!!! ***'; } # Executes. my $a = 1; my $a = cool; my $
And I wouldn't be surprised if there are more related issues...
ihbIn reply to Re: Re: run-time syntax checking
by ihb
in thread run-time syntax checking
by Pardus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |