I'm going to take a hit to guess the real motivation here. Feel free to tell me if I am not mistaken.
I suspect that you are trying to tackle a large, old code base and would like to include restrictions, but you hoped to first understand where the errors will be (and how many there are), without breaking functionality. Unfortunately, since the use strict functions, changing the internal behavior of the Perl parser and interpreter, there is no "freely strict" or, similar to html, any type of "transition" mode.
However, you can split use strict functionality to start moving in the right direction. First, note that there are actually three separate parts:
use strict 'refs';
and only those 'refs' generate runtime errors. Thus, you can easily add use strict qw(vars subs) to each of your files (scripts and modules) and test them with perl -c . If you encounter error messages, comment on use strict or at least depending on which of the two checks failed, and add a comment about the nature of the failure and proceed. Thus, you can quickly (depending on the number of files) determine which files have compile-time errors and return to them later. (If you were more motivated than me at the moment, you could even automate this process). Unless you have code that does scary things inside BEGIN blocks, this should be pretty safe.
The more complex part checks the runtime errors generated by use strict 'refs' and, unfortunately, there really is no easy way to do this, because errors are triggered using symbolic links that cannot be detected by any static analysis such as -c and / or Perl :: Critic are useless.
Hope this comes close to solving your real problem.
source share