2011年3月24日 星期四

將目錄中所有的檔案中的一行COPY到另外一行

$dirname = "C:\\LVT_cells";
opendir(DIR, $dirname) or die "can't opendir $dirname: $!";
while (defined($file = readdir(DIR))) {    
 $dut =  $dirname."\\".$file;
 print $dut."\n";
  open(h1, "<$dut");
  open(h2, ">temp.cir");
  while(<h1>){
   chop $_;
   print h2 $_;
   print h2 "\n";
   @ary=split(" ",$_);
   if($ary[0] eq ".include"){
    $write_back = $_;
    print $write_back."\n";
   }
   
   if($ary[0] eq ".subckt"){
    print h2 $write_back."\n";
    print $write_back;
    print "got it";
   }
   
   if($ary[0] eq ".ends"){
    close(h2);
    rename("temp.cir",$dut.".cir");
    open(h2,">temp.cir");
   }
 }
}
 closedir(DIR);

沒有留言:

張貼留言

標籤