Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

To enhance the script to cover new rules

by freekngeek (Acolyte)
on Jan 09, 2013 at 10:32 UTC ( [id://1012422]=perlquestion: print w/replies, xml ) Need Help??

freekngeek has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am an intern and new to the world of perl. I have to enhance the script with new naming convention so it can parse the new rules. Actually this script is comparing two text files, techfile and referene file. techfile used to have old set of rules and the following script is for the old techfile. Now. I have a new techfile with few new rules, so I have to enhance the old script for the new techfile. Old tech file -

POLYNOMIAL_BASED_EM_DC { LENGTH_RANGES { 1e38 } EM_POLYNOMIALS { { 0.3802 + (13.4739 * sqrt(W/0.9)) + (4.6272 * (W/0.9)) } } } POLYNOMIAL_BASED_EM_RMS { LENGTH_RANGES { 1e38 } EM_POLYNOMIALS { { 0.3802 + (13.4739 * sqrt(W/0.9)) + (4.6272 * (W/0.9)) } } }
New tech file -
POLYNOMIAL_BASED_EM_DC { COND_RULE { L > 0 AND W > 0} EM_POLYNOMIAL { 0.3802 + (13.4739 * sqrt(W/0.9)) + (4.6272 * ( +W/0.9)) IMAX -2.632 + (27.136 * (W/0.9)) } } POLYNOMIAL_BASED_EM_RMS { COND_RULE { L > 0 AND W > 0} EM_POLYNOMIAL { 0.3802 + (13.4739 * sqrt(W/0.9)) + (4.6272 * ( +W/0.9)) } }
Here's the part of the code.

my $rw = open(FILE, $techfile); if(not defined($rw)) { die "ERROR Can't read techfile! \n"; } while(defined(my $i = <FILE>)) { chomp($i); if( $i =~ /metal/ ) { $blockMetal=1; $curlev=&LevelList("metal ",$i); $metals{$curlev}=(); } if( $i =~ /via/ ) { $blockVia=1; $curlev=&LevelList("via ",$i); $vias{$curlev}=(); } #start single metal-level extraction if($blockMetal > 0) { $zBlock=&CharCount($zBlock,$i); if( $i =~ /POLYNOMIAL_BASED_EM_DC/ ) { $blockEMDC=1; } #start extraction #POLYNOMIAL_BASED_EM_DC block for single metal level if($blockEMDC > 0) { $zzBlock=&CharCount($zzBlock,$i); push @readin, $i; #line added to array if($zzBlock == 0) { $blockEMDC=0; $readin=join(' ',@readin); #connect whole block to one + string $_=&CreateHash($readin,\%{$metals{$curlev}{'POLY_BASED +_EM_DC'}},'DC',$eps); #if(!$_) {print("$curlev DC consistent is fine!\n")};# +only for debugging if($_==1){print("$curlev DC lentgh AND width ranges bl +ock is missing!\n")} elsif($_==2){print("$curlev DC count of lentgh-ranges +AND count of EM_POLYNOMIALS blocks doesn't match!\n")} elsif($_==3){print("$curlev DC count of width-ranges A +ND count of EM_POLYNOMIALS block-lines doesn't match!\n")} + undef @readin; undef $readin; undef $zzBlock; } } #end extraction #POLYNOMIAL_BASED_EM_DC block for single metal level

Replies are listed 'Best First'.
Re: To enhance the script to cover new rules
by choroba (Cardinal) on Jan 09, 2013 at 10:49 UTC
    Hello freekngeek, wellcome to the Monastery.

    Unfortunately, this is not a code writing service. What have you tried, what did not work? What parts of the old code do you need to be explained?

    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      Sorry, I really don't want anyone to write a code for me because it's not right. The thing is I am having a hard time understanding the old script that I do not understand 100% - I did not write it. I don't know how this script is working to calculate the values in techfile then matching those values with the reference file. Can you tell me how this part is working ?

      if($blockEMDC > 0) { $zzBlock=&CharCount($zzBlock,$i); push @readin, $i; #line added to array if($zzBlock == 0) { $blockEMDC=0; $readin=join(' ',@readin); #connect whole block to one + string $_=&CreateHash($readin,\%{$metals{$curlev}{'POLY_BASED +_EM_DC'}},'DC'); #if(!$_) {print("$curlev DC consistent is fine!\n")};# +only for debugging if($_==1){print("$curlev DC lentgh AND width ranges bl +ock is missing!\n")} elsif($_==2){print("$curlev DC count of lentgh-ranges +AND count of EM_POLYNOMIALS blocks doesn't match!\n")} elsif($_==3){print("$curlev DC count of width-ranges A +ND count of EM_POLYNOMIALS block-lines doesn't match!\n")} + undef @readin; undef $readin; undef $zzBlock; } }

        Can you tell me how this part is working ?

        Kind of broad and unanswerable :/

        pick a line and explain what you understand, and what you don't understand, or are you asking about something else

        if($_==1){ print("$curlev DC lentgh AND width ranges block is missing!\n")}

        you don't need the parentheses here, same as:

        if($_==1){ print $curlev, ' DC lentgh AND width ranges block is missing!\n'}
Re: To enhance the script to cover new rules
by Anonymous Monk on Jan 09, 2013 at 10:56 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1012422]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-23 06:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found