line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Path::Util; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2021-07-05'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'Path-Util'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.000001'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
87037
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
27
|
|
9
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use Exporter 'import'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
158
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
13
|
|
|
|
|
|
|
basename |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub basename { |
17
|
1
|
|
|
1
|
1
|
1826
|
require File::Spec; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
4
|
my ($path, @suffixes) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# TODO: we haven't canonicalize foo/bar/ -> foo/bar so basename(foo/bar/) -> |
22
|
|
|
|
|
|
|
# ''. |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
19
|
my (undef, undef, $file) = File::Spec->splitpath($path); |
25
|
1
|
|
|
|
|
4
|
for my $s (@suffixes) { |
26
|
0
|
0
|
|
|
|
0
|
my $re = ref($s) eq 'Regexp' ? qr/$s$/ : qr/\Q$s\E$/; |
27
|
0
|
0
|
|
|
|
0
|
last if $file =~ s/$re//; |
28
|
|
|
|
|
|
|
} |
29
|
1
|
|
|
|
|
5
|
$file; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
# ABSTRACT: Path functions |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |