| 1 | package File::Find::Match::Util; | ||||||||||
| 2 | 1 | require 5.008; | |||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use base 'Exporter'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use File::Basename (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | our $VERSION = '0.10'; | |||||||||
| 10 | 1 | our @EXPORT = qw( ); | |||||||||
| 11 | 1 | our @EXPORT_OK = qw( filename ext wildcard ); | |||||||||
| 12 | |||||||||||
| 13 | 2 | ▶ | sub filename ($) { | ||||||||
|
Subroutine
filename: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 14 | 2 | ▶ | my $basename = shift or croak 'Usage: filename($basename)'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | |||||||||||
| 16 | 7 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 17 | 7 | ▶ | croak "filename() predicate passed undef filename!" if not defined $_[0]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 5 | File::Basename::basename($_[0]) eq $basename; | |||||||||
| 19 | 1 | }; | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 3 | ▶ | sub ext ($) { | ||||||||
|
Subroutine
ext: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 23 | 3 | ▶ | my $ext = shift or croak 'Usage: ext($extension)'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | |||||||||||
| 25 | 3 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 26 | 3 | ▶ | my $s = shift or croak "predicate ext($ext) called with bad arguments"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 2 | substr($s, rindex($s, '.') + 1) eq $ext; | |||||||||
| 28 | 1 | }; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 1 | ▶ | sub wildcard ($) { | ||||||||
|
Subroutine
wildcard: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 32 | 1 | ▶ | my $pat = shift or croak 'Usage: wildcard($pattern)'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 1 | my $re = quotemeta $pat; | |||||||||
| 34 | 1 | $re =~ s/\\\*/(.+)/g; | |||||||||
| 35 | 1 | my $regex = qr/$re/; | |||||||||
| 36 | 1 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 37 | 1 | $_[0] =~ $regex; | |||||||||
| 38 | 1 | }; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | |||||||||||
| 42 | 1 | 1; | |||||||||
| 43 | __END__ | ||||||||||