Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: Testing if Perl Code is Valid - but don't execute!

by merlyn (Sage)
on Aug 13, 2010 at 02:27 UTC ( #854812=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Testing if Perl Code is Valid - but don't execute!
in thread Testing if Perl Code is Valid - but don't execute!

No, I would argue that you have to finish parsing the file. Which puts it at a 50% success rate. Unless you have knowledge ahead of time of all possible environments that could succeed or fail in the remaining code.

-- Randal L. Schwartz, Perl hacker

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.


Comment on Re^4: Testing if Perl Code is Valid - but don't execute!
Re^5: Testing if Perl Code is Valid - but don't execute!
by JavaFan (Canon) on Aug 13, 2010 at 08:01 UTC
    Well, duh, you got to finish parsing the file to know whether it's valid or not.

    For the example given though, you don't to execute more than the BEGIN block. That is, afterall, exactly what perl -c does. It executes the BEGIN, parses the file, and then, 100% of the time, tells you whether the file contains a valid Perl program or not.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://854812]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2014-08-21 11:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (134 votes), past polls