in reply to Testing if Perl Code is Valid - but don't execute!
Is there a way to test if Perl code is valid, without having the Perl code you want to validate, affect the rest of the script?No. Consider:
Valid or not? Without executing the begin block, impossible to answer. (It's valid if the prototype is empty, it's a syntax error otherwise.)BEGIN { my $p = rand() < .5 ? '$' : ''; eval "sub foo($p) {1;}"; } foo / 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Testing if Perl Code is Valid - but don't execute!
by merlyn (Sage) on Aug 11, 2010 at 00:39 UTC | |
by JavaFan (Canon) on Aug 11, 2010 at 08:36 UTC | |
by merlyn (Sage) on Aug 13, 2010 at 02:27 UTC | |
by JavaFan (Canon) on Aug 13, 2010 at 08:01 UTC |