Skip to content

[doc] use VERSION - "use 5.12;" vs. "use strict;" and "use 5.35.0;" vs. "use warnings;" #22253

@pullrich

Description

@pullrich

Where

use VERSION

If the specified Perl version is 5.12 or higher, strictures are enabled lexically as with use strict. Similarly, if the specified Perl version is 5.35.0 or higher, warnings are enabled. Later use of use VERSION will override all behavior of a previous use VERSION, possibly removing the strict, warnings, and feature added by it. use VERSION does not load the feature.pm, strict.pm, or warnings.pm files.

https://perldoc.perl.org/functions/use#use-VERSION

Description

I am confused. I thought specifying use 5.12; or higher would behave like use strict; ("... strictures are enabled lexically as with use strict."). But the last sentence in the paragraph warns me that strict.pm is then not loaded ... as it would be when using use strict;? (Same thing with use warnings; and version >= 5.35.0.)

So the correct thing to do, even at version 5.35.0 or later, would still be:

use v5.35.0;
use strict;
use warnings;

... to ensure that strictures and warnings are enabled and the *.pm's are loaded?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions