in reply to Simple replacement - only if they exist..
Okay. . . .I've looked through your previous nodes on this and here (as far as I understand it) is your solution, in pieces.
What you have is a hash with a comma delimited set of values. I'm going to assume you are stuck with this structure. In the *.PIN line, a variable (as you call it) seems to be in the whitepace, name, colon, value format. You want to change the letter appended after the colon on anything inside these comma seperated list, and make this change based on which hash entry these are in. We'll use a regular expression for this.
#Assuming that $variable contains the value to match for #( Something from $runset{GROUND-NODE} ) . . . $line =~ s/ #The substitution operator $variable #vssa, vss, etc . . . : #a colon . #any character (I, O, etc) / #substituted by . . . $variable #as before : #as before G #the G because it's in GROUND-NODE /xg; #Substitute globally
Make sure you understand regexes! If you don't then a simple one will throw you, and that is the solution you need here.
So, now that we has the regex, we just do a couple of iterations, and you are set.
#Complete code! #(Almost . . .) # @lines contains the *PIN lines . . . foreach $PIN (@lines) { foreach $ground_var (split /,/, $runset{GROUND-NODE}) { $PIN =~ s/$ground_var:./$ground_var:G/g; } foreach $power_var (split /,/, $runset{POWER-NODE}) { $PIN =~ s/$power_var:./$power_var:P/g }
Now, if you need explanations, ask and I'll give 'em :-).
Cheers,
|
|---|