in reply to eval, but syntax-check only -- like perl -c

why run without the external call? without your reasoning, it's hard for me to see why any of the solutions posted so far are better... they're full of caveats. if you use File::Temp and perl -c the file, it will work, and can even be configured to clean up after itself. to a user, it should look the same, except it's probably less of a maintenance headache.

~Particle *accelerates*

Replies are listed 'Best First'.
Re: Re: eval, but syntax-check only -- like perl -c
by dpuu (Chaplain) on Apr 24, 2003 at 21:14 UTC
    I guess there's nothing particularly wrong with the system call: indeed, in some ways it works better. For example, "use strict" doesn't work inside an eval.

    One of the nice things about the 'eval "sub { $txt }"' approach is that it gives me a code ref that I can call later if I want. This means that I can have a two-pass approach: in the first I gather/check all my fragments; and in the second I run selected ones. This isn't my current plan, but is nice to have the flexibility.

    --Dave

      there's room for that here, as well. create a hash with nice names as keys, and filehandles or filenames or the code snippets themselves as values. you still have the two-pass approach, but if you write to disk and keep the filehandles or filenames around, you can always slurp them in quickly to run them. heck, you can do with them what you will.

      ~Particle *accelerates*