in reply to Simple replacement - only if they exist..

Assuming I understand the problem correctly, you just need to convert your hashtable values to regexp patterns that match any of the variables, then do a substitution. Something like:
sub replace { my ($line, $nodes, $suffix) = @_; (my $matchNodes = $nodes) =~ s/,/|/g; $line =~ s/\b($matchNodes):./$1:$suffix/g; return $line; } $line = replace($line, $runset{'POWER-NODE'}, 'P'); $line = replace($line, $runset{'GROUND-NODE'}, 'G');

That assumes that there's always a single character after the colon.

Notice the \b -- that prevents it from replacing eg 'xvdd' when your runset contains 'vdd'.