Here is my proposal which has a somewhat simpler logic utilizing the empty string to print nothing:
use strict; use warnings; my $previous=""; while(<DATA>){ if(/XXXXX/){ <DATA>; $previous=""; }else{ print $previous; $previous=$_; } } print $previous; __DATA__ PPPPP XXXXX is my name YYYYY KKKKK UUUUU BBBBB CCCCCC XXXXX is what I play KKKKK NNNNN
In reply to Re: how to check for a word in a file and if found remove that line, the above line and the below line from the file.
by hdb
in thread how to check for a word in a file and if found remove that line, the above line and the below line from the file.
by Ganesh Bharadwaj1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |