perl programming to store column value based on another column value -


i have input in text file :

time(1ps)  *_sysclock *hy_dvdd_0 *y_vdd18_0 *s_enabled *lpi_clk_0 ========== ========== ========== ========== ========== ========== 1000000000 1          1          1          11         1          1000000045 1          1          1          11         0          1000008365 1          1          1          11         1          1000009824 0          1          1          11         1          1000016685 0          1          1          11         0          1000025005 0          1          1          11         1          1000033325 0          1          1          11         0          1000035828 1          1          1          11         0          1000041645 1          1          1          11         1          1000049965 1          1          1          11         0          1000058285 1          1          1          11         1          1000061832 0          1          1          11         1          1000066605 0          1          1          11         0   

what have here : 2nd column indicate clock edge , first column indicate time.. need measure clock frequency. requirement is, since script taking first value depend on time when run script, when clock value changes initial value, in above example initial value 1, when changes 0, time want store column 1 value in 1 variable , when again clock value changes 1 time want store column 1 value clock pulse duration.

based on want compare these timing difference predefined value compare it.

can experts me in solving this.

thanks in advance.

expected o/p : need output tells me difference between edges.. in above example : diff between "1000009824" first changes in clock edge occurs. , "1000061832" clock edge value again comes 0, means full clock cycle.

let's suppose have input coming in on stdin. might want ignore first 2 lines:

<> 1..2; 

then, can read in line of data:

my $line = <>;                   #read line stdin @initial = split(' ', $line);  #split on whitespace 

you can read more lines in until see change:

my @final; while ($line = <>) {     @final = split(' ', $line);     last if $final[1] != $initial[1]; } 

and can compare timestamps:

my $diff = $final[0] - $initial[0]; print "$initial[0] $final[0] $diff\n"; 

i'd recommend reading line hash, have real column names instead of array indices... that's you.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -