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.02 |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.02'; # VERSION |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
15337
|
use utf8; |
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
7
|
|
18
|
2
|
|
|
2
|
|
45
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
29
|
|
19
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
46
|
|
20
|
2
|
|
|
2
|
|
6
|
use List::Util qw/any/; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
162
|
|
21
|
2
|
|
|
2
|
|
8
|
use vars qw/$VERSION @EXPORT_OK/; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
452
|
|
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
|
8
|
return ( any { $_ eq extension( $_[0] ) } @{ $_[1] } ) ? 1 : 0; |
|
2
|
|
|
2
|
|
11
|
|
|
2
|
|
|
|
|
12
|
|
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
|
6
|
return ( !scalar any { $_ eq extension( $_[0] ) } @{ $_[1] } ) ? 1 : 0; |
|
2
|
|
|
2
|
|
5
|
|
|
2
|
|
|
|
|
6
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 extension |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Parse extension from file string. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub extension { |
53
|
18
|
|
|
18
|
1
|
70
|
my ($extension) = $_[0] =~ /((\.[^.\s|(\/|\\|::]+)+)$/; |
54
|
18
|
|
|
|
|
48
|
return $extension; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |