kcott has asked for the wisdom of the Perl Monks concerning the following question:
Background
I'm doing some testing of Perl::Dist::APPerl on various platforms. I have a test script which currently checks that 'use v5.36;' enables the warnings pragma and features are enabled or disabled as appropriate.
Question
I'm looking for a platform-independent way to determine if the strict pragma is in effect without forcing an abort.
If strict is specifically used, it can be determined from %INC:
ken@titan ~/tmp $ perl -e 'use strict; print "$_\n" for keys %INC;' strict.pm ken@titan ~/tmp $ perl -e 'use strict; my $x = xyz;' Bareword "xyz" not allowed while "strict subs" in use at -e line 1. Execution of -e aborted due to compilation errors.
However, if strict is enabled automatically via use VERSION (where VERSION >= 5.12), this method doesn't work:
ken@titan ~/tmp $ perl -e 'use 5.012; print "$_\n" for keys %INC;' ken@titan ~/tmp $ perl -e 'use 5.012; my $x = xyz;' Bareword "xyz" not allowed while "strict subs" in use at -e line 1. Execution of -e aborted due to compilation errors.
Any help with this would be appreciated. Thankyou.
— Ken
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to determine if 'strict' is enabled
by ikegami (Patriarch) on Jun 07, 2023 at 03:58 UTC | |
by stevieb (Canon) on Jun 07, 2023 at 05:16 UTC | |
by kcott (Archbishop) on Jun 07, 2023 at 06:15 UTC | |
by LanX (Saint) on Jun 07, 2023 at 11:27 UTC | |
by kcott (Archbishop) on Jun 07, 2023 at 04:31 UTC | |
Re: How to determine if 'strict' is enabled
by tobyink (Canon) on Jun 12, 2023 at 09:34 UTC |
Back to
Seekers of Perl Wisdom