Suic Suic - 28 days ago 6
Perl Question

Perl no warnings 'experimental' on old 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?

Answer

Try if:

no if ($] >= 5.018), 'warnings' => 'experimental';