I have a piece of code which uses a lot of experimental (when
, smartmatch
, given
) features, it's not my code, and I don't want to see a lot of warnings about experimental features. So I added no warnings 'experimental';
to this code. But experimental
category was added only in perl 5.18 so my code dies in older perls:
Unknown warnings category 'experimental'
How can I disable this warnings and do not break my code in older perls?
Warnings can be disabled selectively by using 'no warning' pragma within a scope along with an argument list. If the argument list is not provided then this pragma will disable all the warnings within that scope. Example: Perl.
The warnings pragma gives control over which warnings are enabled in which parts of a Perl program. It's a more flexible alternative for both the command line flag -w and the equivalent Perl variable, $^W .
Try installing and using the experimental module. On older perls it will do nothing, and on newer perls it will disable the warnings.
use experimental qw(smartmatch switch);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With