[system] / trunk / pg / lib / ww_strict.pm Repository:
ViewVC logotype

Diff of /trunk/pg/lib/ww_strict.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2163 Revision 2164
1package strict; 1package strict;
2
3$strict::VERSION = "1.03";
2 4
3=head1 NAME 5=head1 NAME
4 6
5strict - Perl pragma to restrict unsafe constructs 7strict - Perl pragma to restrict unsafe constructs
6 8
90vars => 0x00000400 92vars => 0x00000400
91); 93);
92 94
93sub bits { 95sub bits {
94 my $bits = 0; 96 my $bits = 0;
95 foreach my $s (@_){ $bits |= $bitmask{$s} || 0; }; 97 my @wrong;
98 foreach my $s (@_) {
99 push @wrong, $s unless exists $bitmask{$s};
100 $bits |= $bitmask{$s} || 0;
101 }
102 if (@wrong) {
103 #require Carp;
104 Carp::croak("Unknown 'strict' tag(s) '@wrong'");
105 }
96 $bits; 106 $bits;
97} 107}
98 108
109my $default_bits = bits(qw(refs subs vars));
110
99sub import { 111sub import {
100 shift; 112 shift;
101 $^H |= bits(@_ ? @_ : qw(refs subs vars)); 113 $^H |= @_ ? bits(@_) : $default_bits;
102} 114}
103 115
104sub unimport { 116sub unimport {
105 shift; 117 shift;
106 $^H &= ~ bits(@_ ? @_ : qw(refs subs vars)); 118 $^H &= ~ bits(@_ ? @_ : qw(refs subs vars));
107} 119}
108 120
1091; 1211;
122__END__
123

Legend:
Removed from v.2163  
changed lines
  Added in v.2164

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9