Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the correct Perl syntax for "use if, feature"?

Tags:

unicode

perl

The pragma use feature 'unicode_strings' is now strongly recommended.

How does one follow that recommendation in a library module that may be used by Perl versions older than v5.12? I tried several variations of

use if $PERL_VERSION >= v5.12, "feature 'unicode_strings'";

and I always get an error like

Can't locate feature 'unicode_strings'.pm in @INC.

The 'feature' pragma is listed in perlmodlib as a standard pragma, so I assume that it works with use if and that I simply don't have the correct syntax.

like image 573
Freon Sandoz Avatar asked Sep 01 '25 03:09

Freon Sandoz


1 Answers

The documentation for the if module says

use if CONDITION, "MODULE", ARGUMENTS;

so

use if $] >= 5.012, "feature", "unicode_strings";
like image 193
ikegami Avatar answered Sep 03 '25 20:09

ikegami