Hi all..

i have three input files as follows...

file1 is common_modify.vhd which has following lines of codes sum_1_SUM0_0 : XOR3 port map(A => b_c, B => a_c, C => c_c, Y => sum_c); a_pad : INBUF port map(PAD => a, Y => a_c); sum_1_CO0_i : MAJ3 port map(A => a_c, B => c_c, C => b_c, Y => N_5);
file2 is nets.txt which has following lines of codes a_c b_c c_c
file3 is enabled_nets.txt which has following lines of codes a_e b_e c_e

i want my perl script to search for a_c, b_c, c_c (file2) at inputs (A or B or C, not in Y) in common_modify.vhd file and replace them by a_, b_e, c_e (i.e. file3)...Here is the perl code i wrote, but it is not modifying as i want...

open (IN1, "<common_modify.vhd") or die; open (IN2, "<nets.txt") or die; open (IN3, "<enabled_nets.txt") or die; open (OUT, ">output_file.vhd") or die; my @nets = <IN2>; my @enabled_nets = <IN3>; while (<IN1>) { foreach $i (0..$#nets){ print OUT if (s/\=\>\s+$nets[$i]\,/\=\> $enabled_nets[$i]\,/); } }

my output file need to be as follows...

sum_1_SUM0_0 : XOR3 port map(A => b_e, B => a_e, C => c_e, Y => sum_c); a_pad : INBUF port map(PAD => a, Y => a_c); sum_1_CO0_i : MAJ3 port map(A => a_e, B => c_e, C => b_e, Y => N_5);

Please correct the mistakes in the code.. Thank you all for your patience to read my post.....


In reply to Please find out the mistake in substitution function in the code?? by sumathigokul

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.