line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package String::Any::Extensions; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding UTF-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
String::Any::Extensions - Get extensions from string possible for files. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
version 0.01 |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.01'; # VERSION |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
14713
|
use utf8; |
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
7
|
|
18
|
2
|
|
|
2
|
|
46
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
29
|
|
19
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
45
|
|
20
|
2
|
|
|
2
|
|
7
|
use List::Util qw/any/; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
188
|
|
21
|
2
|
|
|
2
|
|
7
|
use vars qw/$VERSION @EXPORT_OK/; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
460
|
|
22
|
|
|
|
|
|
|
require Exporter; |
23
|
|
|
|
|
|
|
*import = \&Exporter::import; |
24
|
|
|
|
|
|
|
@EXPORT_OK = qw( exclude extension include); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 include |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
True or false if the file extension is in the including list. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub include { |
33
|
5
|
100
|
|
5
|
1
|
11
|
return ( any { $_ eq extension( $_[0] ) } @{ $_[1] } ) ? 1 : 0; |
|
2
|
|
|
2
|
|
16
|
|
|
2
|
|
|
|
|
22
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 exclude |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
True or false if the file extension is in the excluding list. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub exclude { |
43
|
5
|
100
|
|
5
|
1
|
7
|
return ( !scalar any { $_ eq extension( $_[0] ) } @{ $_[1] } ) ? 1 : 0; |
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
|
|
8
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 extension |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Parse extension from file string. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub extension { |
53
|
12
|
|
|
12
|
1
|
50
|
my ($extension) = $_[0] =~ /((\.[^.\s]+)+)$/; |
54
|
12
|
|
|
|
|
38
|
return $extension; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |