cleanup test
|
1 |
use strict; |
2 |
use warnings; |
|
3 | ||
4 |
use FindBin; |
|
5 |
use File::Basename 'fileparse'; |
|
6 | ||
7 |
my @dirs = grep { -d $_ } glob("$FindBin::Bin/common/*"); |
|
8 |
for my $dir (@dirs) { |
|
9 |
my @files = grep { /table\d\.pm/ } glob("$dir/*"); |
|
10 |
for my $file (@files) { |
|
11 |
|
|
12 |
my $content = do { |
|
13 |
open my $fh, '<', $file; |
|
14 |
local $/; |
|
15 |
<$fh>; |
|
16 |
}; |
|
17 |
|
|
18 |
$content =~ s/table(\d)/TABLE$1/g; |
|
test cleanup
|
19 |
$content =~ s/TABLE2_alias/TABLE2_ALIAS/g; |
20 |
$content =~ s/key(\d)/KEY$1/g; |
|
21 |
|
|
cleanup test
|
22 |
|
23 |
my $base_name = (fileparse($file, qr/\..+$/))[0]; |
|
24 |
$base_name = uc $base_name; |
|
25 |
my $new_file = "$dir/$base_name.pm"; |
|
26 |
|
|
27 |
open my $fh, '>', $new_file |
|
28 |
or die "Can't write file: $!"; |
|
29 |
|
|
30 |
print $fh $content; |
|
31 |
} |
|
32 |
} |