| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Data::Hopen::Util::Filename - functions for manipulating filenames |
|
2
|
|
|
|
|
|
|
package Data::Hopen::Util::Filename; |
|
3
|
1
|
|
|
1
|
|
2070
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
39
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use Data::Hopen::Base; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.000021'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
300
|
use parent 'Exporter'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
6
|
|
|
9
|
|
|
|
|
|
|
our (@EXPORT, @EXPORT_OK, %EXPORT_TAGS); |
|
10
|
|
|
|
|
|
|
BEGIN { |
|
11
|
1
|
|
|
1
|
|
174
|
@EXPORT = qw(); |
|
12
|
1
|
|
|
|
|
3
|
@EXPORT_OK = qw(obj exe lib); |
|
13
|
1
|
|
|
|
|
31
|
%EXPORT_TAGS = ( |
|
14
|
|
|
|
|
|
|
default => [@EXPORT], |
|
15
|
|
|
|
|
|
|
all => [@EXPORT, @EXPORT_OK] |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
6
|
use Class::Method::Modifiers qw(fresh); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
81
|
|
|
20
|
1
|
|
|
1
|
|
6
|
use Config; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
66
|
|
|
21
|
1
|
|
|
1
|
|
6
|
use Data::Hopen; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
360
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Docs {{{1 |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Data::Hopen::Util::Filename - functions for manipulating filenames |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Nothing is exported by default. Each function is available via an OO |
|
32
|
|
|
|
|
|
|
interface or a procedural interface. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# }}}1 |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 obj |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Return the given filename, with the extension of an object file added. |
|
43
|
|
|
|
|
|
|
Usage: |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Data::Hopen::Util::Filename::obj(filename[, -strip=>true]); # procedural |
|
46
|
|
|
|
|
|
|
Data::Hopen::Util::Filename->new->obj(fn[, -strip=>true]); # OO |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
If C<< -strip => >> is given, strip any existing extension first. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 exe |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Return the given filename, with the extension of an executable file added. |
|
53
|
|
|
|
|
|
|
Usage and options are the same as L. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 lib |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Return the given filename, with the extension of a library file added. |
|
58
|
|
|
|
|
|
|
Usage and options are the same as L. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Create obj(), exe(), and lib() in a loop since they share the same skeleton. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
BEGIN { |
|
65
|
1
|
|
|
1
|
|
7
|
foreach my $lrFunction ([qw(obj _o obj_ext .o)], |
|
66
|
|
|
|
|
|
|
[qw(exe _exe exe_ext), ''], |
|
67
|
|
|
|
|
|
|
[qw(lib _a lib_ext .a)]) |
|
68
|
|
|
|
|
|
|
{ |
|
69
|
|
|
|
|
|
|
fresh $lrFunction->[0] => sub { |
|
70
|
0
|
|
|
0
|
|
|
my (undef, %args) = getparameters(__PACKAGE__, [qw(filename; strip)], @_); |
|
71
|
|
|
|
|
|
|
# __PACKAGE__ => Permit OO interface |
|
72
|
0
|
0
|
|
|
|
|
$args{filename} =~ s/\.[^.]*$// if $args{strip}; |
|
73
|
|
|
|
|
|
|
return $args{filename} . |
|
74
|
0
|
|
0
|
|
|
|
($Config{$lrFunction->[1]} // $Config{$lrFunction->[2]} // |
|
|
|
|
0
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$lrFunction->[3]); |
|
76
|
3
|
|
|
|
|
155
|
}; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 new |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Create a new instance for the OO interface. For example: |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my $FN = Data::Hopen::Util::Filename->new; |
|
85
|
|
|
|
|
|
|
say $fn->obj('hello'); # e.g., "hello.o" or "hello.obj" |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
0
|
1
|
|
sub new { bless {}, shift } |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
|
92
|
|
|
|
|
|
|
__END__ |