in reply to Find out, if "use warnings(all)" and "use strict(all)" are used
The same idea works for warnings and ${^WARN_BITS}.#!/usr/bin/perl STRICT: { use strict; my $strict; BEGIN { $strict = $^H } strict_bits($strict); } NO_STRICT: { no strict; my $strict; BEGIN { $strict = $^H } strict_bits($strict); } sub strict_bits { my $h = shift; # from strict.pm my %bitmask = ( refs => 0x00000002, subs => 0x00000200, vars => 0x00000400 ); printf "\$^H = $h = %b\n", $h; print "strict '$_' is ", (($h & $bitmask{$_}) ? 'on' : 'off' ), "\n" for sort keys %bitmask; } __END__ $^H = 1794 = 11100000010 strict 'refs' is on strict 'subs' is on strict 'vars' is on $^H = 256 = 100000000 strict 'refs' is off strict 'subs' is off strict 'vars' is off
My naive understanding is that $^H is attached to a scope (like the "STRICT" block above) during compile-time, in order to make the strict settings work. Apparently you can't access that setting directly during run-time.
Someone with greater B::Deparse-fu will no doubt be able to explain this in more depth.
|
|---|