This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
(Retracted by #12185)
[perl5.git] / lib / warnings / register.pm
CommitLineData
d3a7d8c7
GS
1package warnings::register ;
2
b75c8c73
MS
3our $VERSION = '1.00';
4
4755096e
GS
5=pod
6
7=head1 NAME
8
9warnings::register - warnings import function
10
c5035329
PM
11=head1 SYNOPSIS
12
13 use warnings::register ;
14
15=head1 DESCRIPTION
16
17Create a warnings category with the same name as the current package.
18
19See L<perlmodlib/Pragmatic Modules> and L<perllexwarn>.
20
f758ef95 21=head1 SEE ALSO
22
23L<perllexwarn>
c5035329 24
4755096e
GS
25=cut
26
d3a7d8c7
GS
27require warnings ;
28
29sub mkMask
30{
31 my ($bit) = @_ ;
32 my $mask = "" ;
33
34 vec($mask, $bit, 1) = 1 ;
35 return $mask ;
36}
37
38sub import
39{
40 shift ;
41 my $package = (caller(0))[0] ;
42 if (! defined $warnings::Bits{$package}) {
43 $warnings::Bits{$package} = mkMask($warnings::LAST_BIT) ;
44 vec($warnings::Bits{'all'}, $warnings::LAST_BIT, 1) = 1 ;
45 $warnings::Offsets{$package} = $warnings::LAST_BIT ++ ;
46 foreach my $k (keys %warnings::Bits) {
47 vec($warnings::Bits{$k}, $warnings::LAST_BIT, 1) = 0 ;
48 }
49 $warnings::DeadBits{$package} = mkMask($warnings::LAST_BIT);
50 vec($warnings::DeadBits{'all'}, $warnings::LAST_BIT++, 1) = 1 ;
51 }
52}
53
541 ;