0
## some lines
## cell (a) { area : 0.898; power: 0.867;
....(some parameters values)
}
pin(a1) { power: 0.767; (some more parameters specific to pins)
timing() {
## again some parameters value....
}
我的文件包含大约300个这样的单元,这些单元位于文件之间。我想分析的文件,什么知道所有变量参数,我想下面的代码,但它是没有用的如何从perl文件中提取一些特定的信息?
while (defined($line=<$fh>)) {
if ($line =~ /cell \(\w+\) \{/../cell \(\w+\) \{/) {
print $result "$line \n";
}
}
我想要得到的值在{}也是,但,不知道怎么弄的我的代码中括号内有括号。请帮忙。
感谢ü所有的help..I写了代码考虑到标属性(忽略括号内的所有属性。),但我现在面临一个很奇怪的问题。我在代码中遇到了if($ line =〜/ cell(\ w /../ cell(\ w /))的问题。对于第一个文件,它检测到有单元格的行(字段并从那里开始,但用于第二文件时,它从第一行自身开始
open $result_file1, ">", "file1.txt";
open $result_file2, ">", "file2.txt";
open $fl1, $file1; open $fl2, $file2;
sub file_reader {
($fh, $indx) = @_;
$count = 0;
undef @temp; undef @pram;
while (defined($line=<$fh>)) {
if ($line =~ /cell \(\w/../cell \(\w/) {
if ($indx == "1") {print $result_file1 "$line\n";}
if ($indx == "2") {print $result_file2 "$line\n";}
if ($line =~ /cell \(\w/) {
@temp = split (' ', $line);}
if ($line =~ /\{/) {
$count += 1;}
if ($line =~ /\}/) {
$count = $count - 1; }
if (($line =~ /:/) and ($count == 1)) {
@pram = split (':', $line);
if ($indx == "1") {$file1{$temp[1]}{@pram[1]} = @pram[2];}
elsif ($indx == "2") { $file2{$temp[1]}{@pram[1]} = @pram[2];}
} }}
close $fh;}
file_reader($fl1, "1");
file_reader($fl2, "2");
一块文件1的输出的: 细胞(AND2X1){
cell_footprint : "AND2X1 ";
area : 7.3728 ;
cell_leakage_power : 3.837209e+04;
driver_waveform_rise : "preDrv";
driver_waveform_fall : "preDrv";
pg_pin (VDD) {
voltage_name : "VDD";
pg_type : "primary_power";
}
pg_pin (VSS) {
voltage_name : "VSS";
pg_type : "primary_ground";
}
.......
一块文件2的输出的:
/**********************************************************************
**** ****
**** The data contained in the file is created for educational ****
**** and training purposes only and are not recommended ****
**** for fabrication ****
**** ****
***********************************************************************
**** ****
为什么它无法应用如果条件为我的第二个文件,那么范围?
我们需要一些代码和一些有代表性的样本数据才能够回答。 “类似”不够好 - 它不需要包含真正的值,但必须具有正确的结构。还有一些说明问题的工作代码。和一个理想的输出。没有这些,这个问题是无法回答的。请参阅[问] – Sobrique
细胞(OR2X4){ \t \t ##一些标属性,如(前 - cell_footprint: “OR2X4”) \t \t ##的某些属性中的属性 防爆 - (pg_pin(VDD){ \t \t \t voltage_name: “VDD”; \t \t \t pg_type里面: “primary_power”; \t \t \t定时(){##的一些属性值} \t \t}) 所以,I H我的两个文件里有很多这样的细胞我必须比较两个文件中存在的特定单元格的所有属性。 所以,为此,我想创建一个包含所有参数的数据结构..并且我坚持如何去做.. 请让我知道如果我必须更加清楚。 –
我已经写了以前的代码,首先获取包含有关特定单元格的细节的行,但是我在行匹配单元格(\ w +){...之下获得了所有行。这可能是一个小问题,但是作为即时消息的新的perl,请帮忙。 –