Hi all,

Yesterday I think I asked a a bit more than what I should have. Since then I have broken down the problem considerably, and here is where I'm at.
I have some variables that I need to modify then replace. They are

$runset{"POWER-NODE"}="vdd,vdda"; $runset{"GROUND-NODE"}="vssa,vss";
Now I have a line in a text file that I want to modify
$line = "*.PIN foo:I bar:O vdd:I vssq:I vssa:O";
The rules are simple

  • For any variables in $runset{"POWER-NODE"} that match the core word in $line will become "variable:P" so in this case $runset{"POWER-NODE"} vdd becomes vdd:P and vdda becomes vdda:P in $line
  • This would produce..
    $line = "*.PIN foo:I bar:O vdd:P vssq:I vssa:O";
  • For any variables in $runset{"GROUND-NODE"} that match the core word in $linewill become "variable:G" so in this case $runset{"GROUND-NODE"} vssa becomes vssa:G and vss becomes vss:G in $line
  • This would produce..continuing from previous
    $line = "*.PIN foo:I bar:O vdd:P vssq:I vssa:G";
    Notice that only those variables that exist in both $line and $runset{pwr/gnd} were changed. Also I don't want to actually change the $runset variables only temporarily modify them.

    I hope this is simpler to understand. I think this isn't tough but I am really stuck on this thing..
    Any help would be very much appreciated. Thanks to every one so far that has tried to read through my kludge and help me out


    In reply to Simple replacement - only if they exist.. by Rhodium

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.