| 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 | 2 | our $VERSION = '0.02'; # VERSION | |||||||||
| 16 | |||||||||||
| 17 | 2 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 2 | ▶ | use List::Util qw/any/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 2 | ▶ | use vars qw/$VERSION @EXPORT_OK/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 2 | require Exporter; | |||||||||
| 23 | 2 | *import = \&Exporter::import; | |||||||||
| 24 | 2 | @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 | 2 | ▶ | sub include { | ||||||||
|
Subroutine
include: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 33 | 2 | ▶ | return ( any { $_ eq extension( $_[0] ) } @{ $_[1] } ) ? 1 : 0; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | =head2 exclude | ||||||||||
| 37 | |||||||||||
| 38 | True or false if the file extension is in the excluding list. | ||||||||||
| 39 | |||||||||||
| 40 | =cut | ||||||||||
| 41 | |||||||||||
| 42 | 2 | ▶ | sub exclude { | ||||||||
|
Subroutine
exclude: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 43 | 2 | ▶ | return ( !scalar any { $_ eq extension( $_[0] ) } @{ $_[1] } ) ? 1 : 0; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | =head2 extension | ||||||||||
| 47 | |||||||||||
| 48 | Parse extension from file string. | ||||||||||
| 49 | |||||||||||
| 50 | =cut | ||||||||||
| 51 | |||||||||||
| 52 | 18 | ▶ | sub extension { | ||||||||
|
Subroutine
extension: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 53 | 18 | my ($extension) = $_[0] =~ /((\.[^.\s|(\/|\\|::]+)+)$/; | |||||||||
| 54 | 18 | return $extension; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 2 | 1; | |||||||||
| 58 | |||||||||||
| 59 | __END__ | ||||||||||