in reply to Re: syntax check from within perl
in thread syntax check from within perl

But see discussion elsewhere in the thread.

The reader did not realize that perl -c does not provide a safe way to test syntactical correctness. There is no way to do that in Perl.

For instance suppose that it does a use. There is no way to know if later code is syntactically correct without running the used module. (For instance what functions are exported? This affects what will be trapped as a bareword under strict, and what will not.) But when you do that, the module could do absolutely anything it wanted to.

  • Comment on Re (tilly) 2: syntax check from within perl

Replies are listed 'Best First'.
Re: Re (tilly) 2: syntax check from within perl
by Matts (Deacon) on Mar 03, 2002 at 09:06 UTC
    But safety wasn't the question - merely how to emulate perl -c...

    If you want it safe from malicious intent, we all know you're basically screwed with Perl. You can't not have it execute use bits, because many imports affect the compilation, like use constant. So either you test the compilation or you don't. I believe the author asked to do so.