[Israel.pm] Access to "-c" capabilities from within a Perl script

Offer Kaye offer.kaye at gmail.com
Mon Oct 25 05:53:57 PDT 2004


Hi,
"perl -c script.pl" will compile script.pl and let me know if the
syntax is okay or if there are any problems.

Is there a way to access this capability from within a Perl script, to
try it on a piece of code in a string? E.g.:
   use Syntax::Check;
   syntax_check($code) or die "That code sucks big-time!\n";

P.S., I'm thinking along the lines of
http://search.cpan.org/dist/Test-Pod/ , but for Perl code, not POD. I
know about http://flymake.sourceforge.net/ , but since I don't use
Emacs, it doesn't help me.

P.P.S, I guess a trivial solution would be to save $code to a
temporary file and run perl-c on it, but it seems that something this
basic should have a builtin solution - what am I missing?

Thanks in advance,
-- 
Offer Kaye



More information about the Perl mailing list