Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: regex statement to call variable value is not working??

by sumathigokul (Acolyte)
on May 13, 2015 at 08:25 UTC ( #1126521=note: print w/replies, xml ) Need Help??


in reply to Re: regex statement to call variable value is not working??
in thread regex statement to call variable value is not working??

Thank you... Its working now....

  • Comment on Re^2: regex statement to call variable value is not working??

Replies are listed 'Best First'.
Re^3: regex statement to call variable value is not working??
by marto (Cardinal) on May 13, 2015 at 09:29 UTC

    You've been told about chomp several times now, in relation to this one problem (as noted here). The purpose of this site is to help people learn, not to do work for them. Before posting again review the your existing threads.

Re^3: regex statement to call variable value is not working??
by sumathigokul (Acolyte) on May 13, 2015 at 08:57 UTC

    Hi Corion..

    The code is working fine, but not does my intention function...i modified the code for my need based on your comments as followed...

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

    I want the output file as follows.. (shown only the modifiable lines)

    VCC_i : VCC port map(Y => \VCC\); sum_1_SUM0_0 : XOR3 port map(A => b_e, B => a_e, C => c_e, Y => su +m_c); carry_pad : OUTBUF port map(D => N_5, PAD => carry); a_pad : INBUF port map(PAD => a, Y => a_c);

    but it is printing as follows.. I understood the mistake in the code that since i wrote the print statement inside for loop, it gets only one element of array at a time.. So, do you have any suggestions for this???

    VCC_i : VCC port map(Y => \VCC\); sum_1_SUM0_0 : XOR3 port map(A => b_c, B => a_c, C => c_c, Y => su +m_c); sum_1_SUM0_0 : XOR3 port map(A => b_c, B => a_e, C => c_c, Y => su +m_c); sum_1_SUM0_0 : XOR3 port map(A => b_e, B => a_e, C => c_c, Y => su +m_c); sum_1_SUM0_0 : XOR3 port map(A => b_e, B => a_e, C => c_e, Y => su +m_c); carry_pad : OUTBUF port map(D => N_5, PAD => carry); a_pad : INBUF port map(PAD => a, Y => a_c);

      Maybe you want to remember in your loop if you already printed a line?

      You could also modify your regular expression so it matches for all elements at once instead of doing a loop over it.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1126521]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2020-12-04 06:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (58 votes). Check out past polls.

    Notices?