Uggh, it's a bit shortsighted that there's no built-in function for this. However, after playing a bit, I've found that this can be simulated without having to actually execute the scalar's contents by pre-pending "return;" and testing with eval:
sub syntax_ok { my $source = "return;\n" . shift; eval $source; return 1 unless $@; return 0; }
Thanks!
In reply to Re^2: how to check syntax of code inside a scalar?
by tjking
in thread how to check syntax of code inside a scalar?
by tjking
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |