|Keep It Simple, Stupid|
Testing if Perl Code is Valid - but don't execute!by skazat (Hermit)
|on Aug 10, 2010 at 21:08 UTC||Need Help??|
skazat has asked for the
wisdom of the Perl Monks concerning the following question:
Is there a way to test if Perl code is valid, without having the Perl code you want to validate, affect the rest of the script? eval() just seems like a natural choice:
But that won't work, if say, I want to test if another Perl script validates - and I also don't want the code to affect anything in my own program:
Since you know, who knows what that perl code actually does! That could lead to all sorts of bad things. do() also look enticing, but it still will run the code it... um, does, if there's no problems. Is there a,
in existence? The more I think of it, the more I'm probably asking for a whole lot.
I'm trying to figure something out for a program who's config file format is just Perl code, instead of something intelligent like, INI or $Your_Favorite_Config_Format. Upgrades to the program could potentially hose an installation, if, for example, config variables in the config file don't exist anymore. Casual users who try to edit Perl code can also, easily host the installation.