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
Back to
Seekers of Perl Wisdom