Usually when a feature is truly deprecated, Perl will give a warning (if warnings are enabled) if you use the feature. You can explicitly set warnings to "FATAL" for a given set of warnings. The syntax is discussed in perllexwarn at Fatal Warnings. Since 'depreated' is a class of warnings, you can do this:
use warnings FATAL => qw(deprecated);
Or you may just want to elevate all warnings to fatal:
use warnings FATAL => qw(all);
The next step might be to layer in the use of Perl::Critic. With Perl::Critic you can start with the default criticism, and then elevate the level of severity, as well as add your own custom configuration. For testing purposes, you could use Test::Perl::Critic to enforce code compliance via your test suite. However, there are some caveats to using the test approach. It's usually best to keep the test local to your developer's environment and not force it upon your users. For one thing, your users may have a different Perl::Critic configuration that suddenly makes your distributed code fail. One common practice is to go ahead and distribute the test that uses Test::Perl::Critic, but deactivate the test (using a skip) unless two conditions are met: (1) The user has Test::Perl::Critic installed, and (2) The user sets an environment variable to true that your test can detect; something like "MYDIST_TEST_PERLCRITIC". If those two conditions aren't met, the test should default to gracefully skipping itself.
In my own code I sometimes make use of Perl::Critic. And I've found the "## no critic (some_test)" escape to be helpful for those times where I want to escape out of a test locally without changing the global configuration. It's sort of my way of reminding myself (and Perl::Critic) that I've checked out the suggestion and consider my usage Ok in this case.
Dave
In reply to Re: Is there any way to shut off deprecated, dangerous, dilapidated, or otherwise undesirable language features?
by davido
in thread Is there any way to shut off deprecated, dangerous, dilapidated, or otherwise undesirable language features?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |