Porf/rename_subs.pl untested

filter: Statementstmt 0.0% 0 / 47 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 63 CC 2 SCAR 11.0
CC
2
Cov
0%
replace_name
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.0
1 # perl
2 # rename_subs.pl ---
3 # Author: <peiner@duelx83.ad.ree.renesas.com>
4 # Created: 14 May 2014
5 # Version: 0.01
6  
7 use warnings;
8 use strict;
9  
10 use v5.10;
11  
12 use FileHandle;
13  
14 use File::Path qw(make_path);
15  
16 my $file = 'rename_subs.txt';
17 my $dir = 'Report';
18  
19 my @files;
20  
21 # push (@files, `find $dir -type f -print`;
22 # push (@files, `find $dir -name "*.p[lm]" -print`);
23 # push (@files, `find $dir -name "*.t" -print`);
24 # push (@files, `find $dir -name "*.bat" -print`);
25 # push (@files, `find $dir -name "*.sh" -print`);
26 push (@files, `find $dir -name "*.html" -print`);
27 # print join ("\n",
28  
29 require 'rename_list.pl';
30  
31 my %sub_replacement = get_converter();
32  
33 sub replace_name {
34 my $name = shift;
35  
36 return $sub_replacement{$name} if defined $sub_replacement{$name};
37  
38 return $name;
39 }
40  
41 foreach my $file (@files) {
42 chomp $file;
43 my $fh_inp = new FileHandle($file);
44  
45 unless ($fh_inp) {
46 say "# can't read file $file: $!";
47 next;
48 }
49  
50 my $out_file = "converted_files/$file";
51  
52 my $new_path = $out_file;
53 $new_path =~ s/[^\/]+$//o;
54 say "$new_path";
55 make_path($new_path) unless -d $new_path;
56  
57 my $fh_outp = new FileHandle(">$out_file");
58  
59 unless ($fh_outp) {
60 say "# can't write file $out_file: $!";
61 next;
62 }
63  
64 say "# Convert file $file -------------------------------------- ";
65
66 #my $contents = do { local $/; <$fh> };
67  
68 foreach (<$fh_inp>) {
69 my $line = $_;
70 $line =~ s/(\w+)/replace_name($1)/eog;
71 # print $line;
72 print $fh_outp $line;
73 }
74  
75 next;
76 }
77