line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LEOCHARRE::Basename; |
2
|
3
|
|
|
3
|
|
58232
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
124
|
|
3
|
3
|
|
|
3
|
|
15
|
use vars qw(@EXPORT_OK %EXPORT_TAGS @ISA $VERSION); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
214
|
|
4
|
3
|
|
|
3
|
|
14
|
use Exporter; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
95
|
|
5
|
3
|
|
|
3
|
|
14
|
use Carp; |
|
3
|
|
|
|
|
20
|
|
|
3
|
|
|
|
|
3839
|
|
6
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%02d", q$Revision: 1.8 $ =~ /(\d+)/g; |
7
|
|
|
|
|
|
|
@ISA = qw/Exporter/; |
8
|
|
|
|
|
|
|
@EXPORT_OK = qw(basename basename_ext abs_dir abs_loc_or_die abs_path_or_die abs_dir_or_die abs_file abs_file_or_die abs_loc abs_path dirname filename filename_ext filename_only); |
9
|
|
|
|
|
|
|
%EXPORT_TAGS = ( all => \@EXPORT_OK ); # this was missing \@ a slash, causing errors |
10
|
|
|
|
|
|
|
|
11
|
5
|
|
|
5
|
1
|
2554
|
sub dirname { my $loc = abs_loc($_[0]); filename($loc); } |
|
5
|
|
|
|
|
12
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
*basename_only = \&filename_only; |
14
|
|
|
|
|
|
|
*basename_ext = \&filename_ext; |
15
|
|
|
|
|
|
|
*basename = \&filename; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub filename { |
18
|
24
|
100
|
|
24
|
1
|
2593
|
$_[0] or return; |
19
|
22
|
50
|
|
|
|
246
|
$_[0]=~/([^\/]+)\/*$/ or return; |
20
|
22
|
|
|
|
|
129
|
$1; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub filename_ext { |
24
|
9
|
50
|
|
9
|
1
|
30862
|
my $f = filename(+shift) or return; |
25
|
9
|
50
|
|
|
|
61
|
$f=~/\.([a-z0-9]{1,7})$/i or return; |
26
|
9
|
|
|
|
|
20
|
my $ext = $1; |
27
|
9
|
100
|
|
|
|
58
|
@_ ? _matches_one_of($ext,@_) : $ext; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
sub filename_only { |
30
|
3
|
50
|
|
3
|
1
|
10
|
my $f = filename($_[0]) or return; |
31
|
3
|
|
|
|
|
15
|
$f=~s/\.([a-z0-9]{1,7})$//i; |
32
|
3
|
|
|
|
|
14
|
$f; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub abs_loc { |
36
|
8
|
100
|
|
8
|
1
|
40
|
$_[0] or return; # if left out, returns as if cwd were arg |
37
|
7
|
50
|
|
|
|
23
|
my $a = abs_path($_[0]) or return; |
38
|
7
|
|
|
|
|
77
|
$a=~s/\/[^\/]+\/*$//; |
39
|
7
|
|
|
|
|
40
|
$a; |
40
|
|
|
|
|
|
|
} |
41
|
0
|
0
|
|
0
|
1
|
0
|
sub abs_loc_or_die { abs_loc($_[0]) or die } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub abs_file { |
44
|
2
|
|
|
2
|
1
|
12
|
require Cwd; |
45
|
2
|
|
|
|
|
9
|
require Carp; |
46
|
2
|
50
|
0
|
|
|
136
|
my $abs = Cwd::abs_path($_[0]) or Carp::cluck("Can't Cwd::abs_path($_[0])") and return; |
47
|
2
|
50
|
0
|
|
|
43
|
-f $abs or Carp::cluck("Not file on disk: '$abs'") and return; |
48
|
2
|
|
|
|
|
12
|
$abs; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
sub abs_dir { |
51
|
2
|
|
|
2
|
1
|
49328
|
require Cwd; |
52
|
2
|
|
|
|
|
21
|
require Carp; |
53
|
2
|
50
|
0
|
|
|
166
|
my $abs = Cwd::abs_path($_[0]) or Carp::cluck("Can't Cwd::abs_path($_[0])") and return; |
54
|
2
|
50
|
0
|
|
|
51
|
-d $abs or Carp::cluck("Not dir on disk: '$abs'") and return; |
55
|
2
|
|
|
|
|
18
|
$abs; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
sub abs_path { |
58
|
9
|
|
|
9
|
1
|
53
|
require Cwd; |
59
|
9
|
|
|
|
|
94
|
require Carp; |
60
|
9
|
50
|
0
|
|
|
539
|
my $abs = Cwd::abs_path($_[0]) or Carp::cluck("Can't Cwd::abs_path($_[0])") and return; |
61
|
9
|
50
|
0
|
|
|
166
|
-e $abs or Carp::cluck("Not on disk: '$abs'") and return; |
62
|
9
|
|
|
|
|
49
|
$abs; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub abs_path_or_die { |
66
|
0
|
|
|
0
|
1
|
0
|
require Cwd; |
67
|
0
|
|
|
|
|
0
|
require Carp; |
68
|
0
|
0
|
|
|
|
0
|
my $abs = Cwd::abs_path($_[0]) or Carp::croak("Can't Cwd::abs_path('$_[0]')"); |
69
|
0
|
0
|
|
|
|
0
|
-e $abs or Carp::croak("Not on disk: '$abs'"); |
70
|
0
|
|
|
|
|
0
|
$abs; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
sub abs_file_or_die { |
73
|
2
|
|
|
2
|
1
|
10
|
require Cwd; |
74
|
2
|
|
|
|
|
7
|
require Carp; |
75
|
2
|
50
|
|
|
|
124
|
my $abs = Cwd::abs_path($_[0]) or Carp::croak("Can't Cwd::abs_path('$_[0]')"); |
76
|
2
|
100
|
|
|
|
326
|
-f $abs or Carp::croak("Not file on disk: '$abs'"); |
77
|
1
|
|
|
|
|
5
|
$abs; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
sub abs_dir_or_die { |
80
|
1
|
|
|
1
|
1
|
39199
|
require Cwd; |
81
|
1
|
|
|
|
|
9
|
require Carp; |
82
|
1
|
50
|
|
|
|
79
|
my $abs = Cwd::abs_path($_[0]) or Carp::croak("Can't Cwd::abs_path('$_[0]')"); |
83
|
1
|
50
|
|
|
|
19
|
-d $abs or Carp::croak("Not dir on disk: '$abs'"); |
84
|
1
|
|
|
|
|
9
|
$abs; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub _matches_one_of { |
88
|
6
|
|
|
6
|
|
9
|
my $string = shift; |
89
|
|
|
|
|
|
|
|
90
|
6
|
|
|
|
|
26
|
for my $arg ( @_ ){ |
91
|
8
|
100
|
|
|
|
38
|
ref $arg or (($string eq $arg) ? return 1 : next); |
|
|
100
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
3
|
100
|
|
|
|
14
|
if (ref $arg eq 'ARRAY'){ |
|
|
50
|
|
|
|
|
|
94
|
1
|
50
|
|
|
|
7
|
map { ( $string eq $_ ) and return $string } @$arg; |
|
2
|
|
|
|
|
12
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
elsif ( ref $arg eq 'Regexp' ){ |
98
|
2
|
100
|
|
|
|
21
|
$string=~$arg and return $string; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
3
|
|
|
|
|
283
|
return; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |