in reply to Re^6: Delete a line from the file
in thread Delete a line from the file
Instead of doing an in-place replace , You can redirect the output of this to the final file.perl -ne 'BEGIN{ $s=q ~(.*)$/'"'"',$lines,$matches) 10.(.*)$/'" +'"',$lines,$matches) (.*)$/'"'"',$lines,$matches)~};print unless +/\Q$s\E/' input.txt
It seems like "\Q" and the "$" symbol do not interact well when directly in a RE.
If you put the "$" symbols outside \Q..\E , it seems to work.
Here is the quote from http://www.perl.com/doc/manual/html/pod/perlre.html
You cannot include a literal $ or @ within a \Q sequence. An unescaped $ or @ interpolates the corresponding variable, while escaping will cause the literal string \$ to be matched. You'll need to write something like m/\Quser\E\@\Qhost/.
So, this one works too ..(But it sure is UGLY!)
perl -ne 'print unless m~\Q(.*)\E\$/'"'"',\$lines,\$matches\Q) + 10.(.*)\E\$/'"'"',\$lines,\$matches\Q) (.*)\E\$/'"'"',\$lines,\$ +matches\)~x' input.txt
Have you been high today? I see the nuns are gay! My brother yelled to me...I love you inside Ed - Benny Lava, by Buffalax
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Delete a line from the file
by Anonymous Monk on Jul 17, 2008 at 16:20 UTC |