How can I perform a “shallow” syntax check on perl files. The standard perl -c is useful but it checks the syntax of imports. This is sometimes nice but not great when you work in a code repository and push to a running environment and you have a function defined in the repository but not yet pushed to the running environment. It fails checking a function because the imports reference system paths (ie. use Custom::Project::Lib qw(foo bar baz)).
How can I perform a shallow syntax check on perl files. The standard perl
Share
It can’t practically be done, because imports have the ability to influence the parsing of the code that follows. For example
use strictmakes it so that barewords aren’t parsed as strings (and changes the rules for how variable names can be used),use constantcauses constant subs to be defined, anduse Try::Tinychanges the parse of expressions involvingtry,catch, orfinally(by giving them&prototypes). More generally, any module that exports anything into the caller’s namespace can influence parsing because the perl parser resolves ambiguity in different ways when a name refers to an existing subroutine than when it doesn’t.