File Coverage

blib/lib/Enum/Declare/Common/Permission.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 15 15 100.0


line stmt bran cond sub pod time code
1             package Enum::Declare::Common::Permission;
2              
3 1     1   91801 use 5.014;
  1         3  
4 1     1   4 use strict;
  1         1  
  1         20  
5 1     1   2 use warnings;
  1         2  
  1         48  
6              
7 1     1   373 use Enum::Declare;
  1         11079  
  1         353  
8              
9             enum Bit :Flags :Type :Export {
10             Execute,
11             Write,
12             Read
13             };
14              
15             enum Mask :Type :Export {
16             OwnerRead = 256,
17             OwnerWrite = 128,
18             OwnerExecute = 64,
19             GroupRead = 32,
20             GroupWrite = 16,
21             GroupExecute = 8,
22             OtherRead = 4,
23             OtherWrite = 2,
24             OtherExecute = 1
25             };
26              
27             1;
28              
29             =head1 NAME
30              
31             Enum::Declare::Common::Permission - Unix permission bits and masks
32              
33             =head1 SYNOPSIS
34              
35             use Enum::Declare::Common::Permission;
36              
37             # Flags
38             my $rwx = Read | Write | Execute; # 7
39             my $rw = Read | Write; # 6
40              
41             # Mask constants for chmod-style values
42             my $mode = OwnerRead | OwnerWrite | OwnerExecute
43             | GroupRead | GroupExecute
44             | OtherRead | OtherExecute; # 0755
45              
46             =head1 ENUMS
47              
48             =head2 Bit :Flags :Export
49              
50             Execute=1, Write=2, Read=4. Combinable with bitwise OR.
51              
52             =head2 Mask :Export
53              
54             OwnerRead=256, OwnerWrite=128, OwnerExecute=64, GroupRead=32,
55             GroupWrite=16, GroupExecute=8, OtherRead=4, OtherWrite=2,
56             OtherExecute=1.
57              
58             =head1 AUTHOR
59              
60             LNATION C<< >>
61              
62             =head1 LICENSE AND COPYRIGHT
63              
64             Copyright 2026 LNATION. Artistic License 2.0.
65              
66             =cut