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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|