#!/usr/bin/perl
#use strict;
#use warnings;
$dir = "TYP";
opendir(DIR, $dir) or die $!;
while (my $file = readdir(DIR)) {
# Use a regular expression to ignore files beginning with a period
next if ($file =~ m/^\./);
print "$file\n";
@ary=split("_",$file);
print "$ary[0]\n";
$current_file_name="$dir/$file/change_cell.dist";
print "$current_file_name\n";
open(tempfile,"<$current_file_name");
open(h2,">temp.cir");
while( ){
chop $_;
print $_;
s/change_cell.dist.pex/$ary[0].dist.pex/g ;
s/ P / pmos_33 /g ;
s/ N / nmos_33 /g ;
print h2 $_;
print h2 "\n";
}
close(h2);
rename("temp.cir",$ary[0].".cir");
open(h2,">temp.cir");
$src = "$dir/$file/change_cell.dist.pex";
$dst = "$ary[0].dist.pex";
use File::Copy;
copy($src, $dst);
}
close (tempfile);
close (h2);
closedir(DIR);
exit 0;