Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Check if perl code is valid

by jdgamache (Novice)
on Jan 14, 2001 at 23:47 UTC ( [id://51798]=perlquestion: print w/replies, xml ) Need Help??

jdgamache has asked for the wisdom of the Perl Monks concerning the following question:

Here is my problem, I want to build a perl code library. I need to validate the perl code entered. here is what i do:
# check to see if code is valid sub check_valid_code { my ($lang, $code) = @_; if ($lang eq 'perl') { $code .= "\n1;\n"; return eval ($code); } 0; }
well.... this validates the code all right! the problem is that it executes the perl code also ;) I need another way to check if the code is valid... but does not execute it. any ideas ?!? thanks! Jean-Daniel

Replies are listed 'Best First'.
Re: Check if perl code is valid
by merlyn (Sage) on Jan 15, 2001 at 00:00 UTC
      I may be missing something here, but couldn't you check the return value of a system('perl -c...')?

      (and before this gets --'d too much, explain why it's a bad idea..)

      -marius
Re: Check if perl code is valid
by I0 (Priest) on Jan 15, 2001 at 00:07 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://51798]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-24 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found