perl脚本整理

########################################script 1#####################################

#####################################################################################

#####################################################################################

#! /usr/bin/perl -w

system('rm -rf  50cal.txt');

my $counter=0;

my $m=0;

my $percent=0;

use constant num => 50;  # it depends on the num of endpoint

use constant threshold => 50;

open (end50, "<50num.txt");

 

while(<end50>){

        $m++;

        if($m<num){

                 print ("m is $m \n");

            if($_<=threshold){

                 $counter++;

                 print ("var is $_ ");

                 print ("counter is $counter \n");

             }

        }else{

         $percent=$counter/num;

            if($percent>=0.8){

                system("echo '$counter' >> 50cal.txt ");

                system("echo '$percent' >> 50cal.txt ");

                $counter=0;

                $m=0;

                next;

            }

         }

            }                    

close end50;

########################################script 1#####################################

#####################################################################################

#####################################################################################

 

########################################script 2#####################################

#####################################################################################

#####################################################################################

#! /usr/bin/perl -w

#open (dff_timing, "<DFF_60.txt");

#open (temp, "<temp.txt");

system('rm -rf  temp.txt');

open dff_timing,'<', 'DFF_60.txt';

open temp,'>', './temp.txt';

open final_data, '>', 'final.txt';

#@array=<dff_timing>;

my $num=0;

my $flag=0;

while(<dff_timing>){

#    $count++;

#   print ("the num timing of DFF $count \n");

    if(/Startpoint/){

        $num++;

        print  temp $num;

        print  temp $_;

        #print ("the num timing of DFF $num \n");

        #system("echo '$num' >> temp.txt ");

     }

     #if(/[67]\.\d\d/){

    if(/6\.[2-9]\d|7\.[12]\d/){

        for($flag=0;$flag<=1;$flag++){

        print temp $_;

        $_=<dff_timing>;

        }

    }else{

        #system("echo 'null\n' >> temp.txt ");

        #print  temp "null\n";

     }

}

system ("cat temp.txt |sed '/net/!d' |cut -d ' ' -f 3 |sort -n|uniq -c|sed 's/^ *//'|sort -n > final.txt");

close dff_timing;

close temp;

close final_data;

########################################script 2#####################################

#####################################################################################

#####################################################################################

 

########################################script 3#####################################

#####################################################################################

#####################################################################################

#! /usr/bin/perl -w

#open (dff_timing, "<DFF_60.txt");

#open (temp, "<temp.txt");

system('rm -rf  temp.txt');

 

open dff_timing,'<', 'allDFF.txt';

open temp,'>', './temp.txt';

open final_data, '>', 'final.txt';

 

my $num=0;

my $flag=0;

my $counter=0;

my $target=0;

my $line_counter=0;

while(<dff_timing>){

    if(/Startpoint/){

        $num++;

        print  temp $num;

        print  temp $_;

     }

     if(/13\.[4-9]\d|14\.[0-5]\d/){

        $line_counter=0;

        print temp $_ ;

        $line_counter++;

    }elsif($line_counter<2){

        print temp $_;

         $line_counter++;

        # print  temp "null\n";

     }

}

 

system ("cat temp.txt |sed '/net/!d' |cut -d ' ' -f 3 |sort -n|uniq -c|sed 's/^ *//'|sort -n > final.txt");

close dff_timing;

close final_data;

close temp;

 

open temp,'<', './temp.txt';

open uncover, '>' , 'uncover_dff_path.txt';

while(<temp>){

    $counter++;

    if(/(Startpoint)/){

        if($counter>1){

                 if($counter-$target==1){

                     #print uncover $b ;

                     #$b=$_;

                    print uncover $_;

                    }

        }

                    $target=$counter;

    }

}

close temp;

close uncover;

########################################script 3#####################################

#####################################################################################

#####################################################################################

 

 

########################################script 4#####################################

#####################################################################################

#####################################################################################

#! /usr/bin/perl -w

 

#system("cp bak.txt test.txt");

#system("cp bak.txt 222.txt");

@nodes =qw /n/;

my $i=0;

my $j=0;

my $m=0;

my $no_match_lines=0;

my $counter=0;

my $match=0;

@start=();

@end=();

@flag=();

 

foreach $node (@nodes){

                print "the node is $node \n";

                system("cat test.txt");

# step 1

open input_file, "<", 'test.txt';

    while(<input_file>){

            if(/Startpoint/){

                $start[$i]=$.;

                $i++;

            }

            if(/endpoint/){

                $end[$j]=$.;

                $j++;

            }

        }

    close input_file;

 

    print "@start";

    print "\n";

    print "----------------------\n";

    print "@end";

    print "\n";

 

#step 2

open input_file, "<", 'test.txt';

    while(<input_file>){

         if(($. >= ($start[$counter]))&&($. <= ($end[$counter]))){

                print "counter is $counter \n";

                #$match=$end[$counter]-$start[$counter]-1;

                $match=$end[$counter]-$start[$counter]+1;

                if($match==2){

                    $counter++;

                    next;

                }

                print "match is $match \n";

            if(/$node/){

                print "$. \n";

                print "----------------------\n";

                $flag[$m]=$counter;

                $m++;

                $counter++;

                $no_match_lines=0;

            }else{

                $no_match_lines++;

                    print "no match lines is $no_match_lines \n";

                if($no_match_lines==$match){

                    print "no match lines is $no_match_lines \n";

                    print "counter is $counter \n";

                    print "----------------------\n";

                    $no_match_lines=0;

                    $counter=$counter+1;

                }

            }

         }

     }

        close input_file;

 

    print "----------------------\n";

    print "@flag";

    print "\n";

    foreach $flag(@flag){

            system("sed -i '$start[$flag],$end[$flag]s/.*//g' 222.txt");

    }

            system("awk NF 222.txt > test.txt");

            system("cp test.txt 222.txt");

# step 3

           $counter=0;

           $m=0;

           $no_match_lines=0;

           $i=0;

           $j=0;

           @start=();

           @end=();

           @flag=();

}

########################################script 4#####################################

#####################################################################################

#####################################################################################

 

 

########################################script 5#####################################

#####################################################################################

#####################################################################################

#! /usr/bin/perl -w

use strict;

use warnings;

#step_1

open input_file,'<', '111.v';

open temp_1,'>', 'temp_1.v';

 

my $num=1;

 

while(<input_file>){

    if(s/monitor_TD(\s+)TD_1(\s+)\(\.Q\(TD_error_1\)(.*)/monitor_TD$1TD_$num$2\(\.Q\(TD_error_$num\)$3/){

        $num++;

         print  temp_1 $_;

    }

}

 

close input_file;

close temp_1;

 

#step_2

open  temp_1,'<', 'temp_1.v';

open  temp_2,'>', 'temp_2.v';

 

my $line=0;

 

my @nodes =qw /n423 DP_OP_386J1_124_2936_n293 n447 n475 DP_OP_386J1_124_2936_n550 DP_OP_386J1_124_2936_n355 DP_OP_386J1_124_2936_n548 n461 n206 n191 DP_OP_386J1_124_2936_n377 DP_OP_386J1_124_2936_n341 DP_OP_386J1_124_2936_n562 DP_OP_386J1_124_2936_n745 n127 DP_OP_386J1_124_2936_n551 DP_OP_386J1_124_2936_n342 DP_OP_386J1_124_2936_n797 DP_OP_386J1_124_2936_n731 DP_OP_386J1_124_2936_n120 DP_OP_386J1_124_2936_n339 DP_OP_386J1_124_2936_n145 n474 n500 DP_OP_386J1_124_2936_n536 DP_OP_386J1_124_2936_n146 DP_OP_386J1_124_2936_n14 DP_OP_386J1_124_2936_n313 n79 DP_OP_386J1_124_2936_n325 DP_OP_386J1_124_2936_n135 n406/;

 

my @array=<temp_1>;

foreach my $nodes (@nodes){

    #chomp($array[$line]);

    if($array[$line] =~ s/n111111/$nodes/){

              print  temp_2 $array[$line];

              $line++;

                           }

}

 

 

close temp_1;

close temp_2;

########################################script 5#####################################

#####################################################################################

#####################################################################################

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值