in reply to How to do a "perl -c(w)" check instead of an "eval $string" on a code string
Where you'll then need to scrape the $result string to find out if it passed or failed.my $result = qx/ perl -cw -e '$code' 2>&1/;
There's another angle to the problem though, you'll need to run the $code through some sort of shell quoting routine, to make sure you don't confuse the shell with characters in perl that also happen to be significant to the shell. I think the cpan module String::ShellQuote works okay for this.
(Note: updated, stealing a hint from shmem to append 2>&1 to the command, this makes sure you'll capture error messages to $result.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to do a "perl -c(w)" check instead of an "eval $string" on a code string
by Your Mother (Archbishop) on Jan 20, 2009 at 00:55 UTC |