Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Problem in Commenting lines in perl

by k_manimuthu (Monk)
on Dec 28, 2010 at 06:35 UTC ( #879378=note: print w/replies, xml ) Need Help??


in reply to Problem in Commenting lines in perl

It's having problem to the 'foreach loop'. It checks the key term and print the content twice. To avoid this kind of circumstance, you may use the ‘next’ statement when you match string found.

while( <$in>) { foreach $ip(@ip) { print $out "#" and next if(/\b$ip\b/i && !/^#/); #only one # at fro +nt of line } print $out $_; }

Replies are listed 'Best First'.
Re^2: Problem in Commenting lines in perl
by GrandFather (Sage) on Dec 28, 2010 at 06:53 UTC

    Except that prints each line once for each match word if none of the matches are found in a line, and in any case once for each mismatched word before a match is found.

    True laziness is hard work
Re^2: Problem in Commenting lines in perl
by vr786 (Sexton) on Dec 28, 2010 at 06:59 UTC

    Thank you k_manimuthu, its working fine.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://879378]
help
Chatterbox?
[Corion]: Two-way data binding means that if you change something in a text box, the corresponding variable in your Javascript gets updated immediately as well, and if you then change the variable, the corresponding text box also gets updated
[Corion]: That is a horrible approach that was also taken by Access, but if you have hooks that prevent automatic saving to the database, it is incredibly handy

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-03-30 07:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (355 votes). Check out past polls.