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 $_; }
In reply to Re: Problem in Commenting lines in perl
by k_manimuthu
in thread Problem in Commenting lines in perl
by vr786
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |