diff options
author | Nicholas Clark <nick@ccl4.org> | 2002-09-08 23:36:09 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2002-09-09 20:35:34 +0000 |
commit | 4b2eca7a72ce307ed58cc8af1ec195a6dc39d730 (patch) | |
tree | 2be421c33b08ec4158a88382c0d4f66d11ebe01e /lib | |
parent | 912440bebca4a2e8a42a1d56c8be458397341faf (diff) | |
download | perl-4b2eca7a72ce307ed58cc8af1ec195a6dc39d730.tar.gz |
strict.pm pod at __END__
Message-ID: <20020908213608.GM286@Bagpuss.unfortu.net>
p4raw-id: //depot/perl@17885
Diffstat (limited to 'lib')
-rw-r--r-- | lib/strict.pm | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/lib/strict.pm b/lib/strict.pm index c89edbf00f..2eb756c938 100644 --- a/lib/strict.pm +++ b/lib/strict.pm @@ -1,5 +1,44 @@ package strict; +$strict::VERSION = "1.02"; + +my %bitmask = ( +refs => 0x00000002, +subs => 0x00000200, +vars => 0x00000400 +); + +sub bits { + my $bits = 0; + my @wrong; + foreach my $s (@_) { + push @wrong, $s unless exists $bitmask{$s}; + $bits |= $bitmask{$s} || 0; + } + if (@wrong) { + my $useno = { + __PACKAGE__.'::import' => 'use', + __PACKAGE__.'::unimport' => 'no' + }->{ (caller(1))[3] }; + require Carp; + Carp::croak("Don't know how to '$useno ".__PACKAGE__." qw(@wrong)'"); + } + $bits; +} + +sub import { + shift; + $^H |= bits(@_ ? @_ : qw(refs subs vars)); +} + +sub unimport { + shift; + $^H &= ~ bits(@_ ? @_ : qw(refs subs vars)); +} + +1; +__END__ + =head1 NAME strict - Perl pragma to restrict unsafe constructs @@ -87,43 +126,4 @@ appears in curly braces or on the left hand side of the "=E<gt>" symbol. See L<perlmodlib/Pragmatic Modules>. - =cut - -$strict::VERSION = "1.02"; - -my %bitmask = ( -refs => 0x00000002, -subs => 0x00000200, -vars => 0x00000400 -); - -sub bits { - my $bits = 0; - my @wrong; - foreach my $s (@_) { - push @wrong, $s unless exists $bitmask{$s}; - $bits |= $bitmask{$s} || 0; - } - if (@wrong) { - my $useno = { - __PACKAGE__.'::import' => 'use', - __PACKAGE__.'::unimport' => 'no' - }->{ (caller(1))[3] }; - require Carp; - Carp::croak("Don't know how to '$useno ".__PACKAGE__." qw(@wrong)'"); - } - $bits; -} - -sub import { - shift; - $^H |= bits(@_ ? @_ : qw(refs subs vars)); -} - -sub unimport { - shift; - $^H &= ~ bits(@_ ? @_ : qw(refs subs vars)); -} - -1; |