in reply to Matching first Perl statement.

I hate to be a nitpicker... but for example
while(1) { for(1..10) { print "foo" } print "\n" }
is valid perl code, yet fails to comply to basic rules on how statements should look like. Well ok, I cheated a bit, but it wasn't all THAT hard :)
People have been praying for years that Damian Conway would write a perl parser in perl.... It seems to me that this would be the only, foolproof way to solve your problem.
Ofcourse I could be mistaking... after all, there is more than one way to do it :)

Greetz
Beatnik
... Quidquid perl dictum sit, altum viditur.