Skip to content

Simplify strict.pm #22848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: blead
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/strict.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package strict;

$strict::VERSION = "1.13";
$strict::VERSION = "1.14";

my ( %bitmask, %explicit_bitmask );

Expand All @@ -12,12 +12,15 @@ BEGIN {
if __FILE__ !~ ( '(?x) \b '.__PACKAGE__.' \.pmc? \z' )
&& __FILE__ =~ ( '(?x) \b (?i:'.__PACKAGE__.') \.pmc? \z' );

# which strictures are actually in force
%bitmask = (
refs => 0x00000002,
subs => 0x00000200,
vars => 0x00000400,
);

# which strictures have at some point been turned on or off explicitly
# and must therefore not be touched by any subsequent `use VERSION` or `no VERSION`
%explicit_bitmask = (
refs => 0x00000020,
subs => 0x00000040,
Expand All @@ -38,12 +41,12 @@ BEGIN {
}

sub bits {
my $do_explicit = caller eq __PACKAGE__;
my $bits = 0;
my @wrong;
foreach my $s (@_) {
if (exists $bitmask{$s}) {
$^H |= $explicit_bitmask{$s};

$bits |= $explicit_bitmask{$s} if $do_explicit;
$bits |= $bitmask{$s};
}
else {
Expand All @@ -66,7 +69,9 @@ sub unimport {
shift;

if (@_) {
$^H &= ~&bits;
my $bits = &bits;
$^H &= ~$bits;
$^H |= all_explicit_bits & $bits;
}
else {
$^H &= ~all_bits;
Expand All @@ -75,6 +80,7 @@ sub unimport {
}

1;

__END__

=head1 NAME
Expand Down