in reply to How to do a "perl -c(w)" check instead of an "eval $string" on a code string
Well, you can set $^C at runtime (or rather, at BEGIN time):
eval 'BEGIN { $^C = 1 } ' . $code; # where $code contains what you wan +t to test
then test $@ for any compile error messages.
Of course, eval has problems, as you've already discussed; so to deal with that, you could use Safe:
use Safe; my $compartment = new Safe; $compartment->reval( 'no warnings; BEGIN { $^C = 1 } ' . $code );
Tested. :-)
|
|---|
| 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 05:54 UTC |