#! perl -slw use strict; while() { 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 check'; } __END__ INIT { print '*** GOTCHA!!! ***'; } BEGIN{ print '*** GOTCHA!!! ***'; } END { print '*** GOTCHA!!! ***'; } my $a = 1; my $a = cool; my $