![]() |
|
Don't ask to ask, just ask | |
PerlMonks |
Re^3: how to comment the lines if found a matchby gwadej (Chaplain) |
on Dec 05, 2008 at 21:59 UTC ( #728397=note: print w/replies, xml ) | Need Help?? |
You are misunderstanding the use of grep. In your example, grep will always return $l unless $m happens to be 0 or an empty string. Instead of grep, you probably want a regular expression.
You probably also want to use chomp in the outer loop to remove the line ending from $m. You are also writing the file multiple times with different lines commented each time. You might want to generate a list of the expressions to match at the beginning and then loop over the file once.
G. Wade
In Section
Seekers of Perl Wisdom
|
|