DBIx-Custom / t / create_uppercase_module.pl /
Newer Older
29 lines | 0.65kb
cleanup test
Yuki Kimoto authored on 2011-08-15
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;
19
      
20
      my $base_name = (fileparse($file, qr/\..+$/))[0];
21
      $base_name = uc $base_name;
22
      my $new_file = "$dir/$base_name.pm";
23
      
24
      open my $fh, '>', $new_file
25
        or die "Can't write file: $!";
26
      
27
      print $fh $content;
28
    }
29
}