line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::FileRenameUtils; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
67841
|
use 5.010001; |
|
1
|
|
|
|
|
11
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use Exporter 'import'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
104
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
10
|
|
|
|
|
|
|
our $DATE = '2023-05-24'; # DATE |
11
|
|
|
|
|
|
|
our $DIST = 'App-FileRenameUtils'; # DIST |
12
|
|
|
|
|
|
|
our $VERSION = '0.011'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = qw(add_filename_suffix find_unique_filename); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub add_filename_suffix { |
17
|
1
|
|
|
1
|
|
7
|
no warnings 'uninitialized'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
186
|
|
18
|
|
|
|
|
|
|
|
19
|
7
|
|
|
7
|
1
|
2398
|
my ($filename, $suffix) = @_; |
20
|
7
|
|
|
|
|
64
|
$filename =~ s/(.+?)(\.\w+)?\z/$1 . $suffix . $2/e; |
|
7
|
|
|
|
|
33
|
|
21
|
7
|
|
|
|
|
97
|
$filename; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub find_unique_filename { |
25
|
4
|
|
|
4
|
1
|
2679
|
my $filename = shift; |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
8
|
my $orig_filename = $filename; |
28
|
4
|
|
|
|
|
6
|
my $i = 0; |
29
|
4
|
|
|
|
|
90
|
while (-e $filename) { |
30
|
5
|
|
|
|
|
14
|
$i++; |
31
|
5
|
|
|
|
|
18
|
$filename = add_filename_suffix($orig_filename, " ($i)"); |
32
|
|
|
|
|
|
|
} |
33
|
4
|
|
|
|
|
31
|
$filename; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
# ABSTRACT: Utilities related to renaming/moving files |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |