Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl no warnings 'experimental' on old perl

Tags:

warnings

perl

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?

like image 225
Suic Avatar asked Jul 09 '14 11:07

Suic


People also ask

How do I turn off warnings in Perl?

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.

What option do you use when starting Perl to tell it to run in warning mode?

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 .


1 Answers

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);
like image 127
AKHolland Avatar answered Oct 03 '22 11:10

AKHolland