Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by Corion (Patriarch)
on May 13, 2015 at 07:42 UTC ( [id://1126513]=note: print w/replies, xml ) Need Help??


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

Each element of @nets contains a newline character, while your target strings don't contain the newline character. See chomp.

Replies are listed 'Best First'.
Re^2: regex statement to call variable value is not working??
by sumathigokul (Acolyte) on May 13, 2015 at 08:25 UTC

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

      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.

      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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1126513]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-03-29 01:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found