in reply to Re^2: Interpolate variable into regexp at time of definition rather than execution, as a filter for Path::Iterator::Rule
in thread Interpolate variable into regexp at time of definition rather than execution, as a filter for Path::Iterator::Rule
> (It is unfortunate that the subtraction like that only warrants an error at run time and doesn't cause perl to refuse to run the program. I do of course have "use warnings;" and "use strict;" already.)
you can always turn warnings fatal to make Perl die on the spot.
~$ perl -e'use warnings FATAL=>"all"; my $x-1; print "never executed"' Useless use of subtraction (-) in void context at -e line 1. ~$
(use FATAL => "void" to only terminate this particular warning class, see perldiag ° )
That's a good strategy for unit tests anyway where unexpected warnings shouldn't appear. Not sure if I'd like to have this in much longer, hence messier production code.
You can probably also apply Perl::Critic or another linter for this to happen statically at compile time.
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
°) one reason this might not warn at compile time is that you still have a "side effect" in the declaration of my $int - hence this could be intended code (?)
I think an optional pragma to make some warning classes die at compile time is worth a consideration.
|
|---|