You're viewing a comment by Rahul and its responses.

Rahul Permalink
March 10, 2016, 06:38

Iam trying to remove a test segment frequently occurs in a file. I have a matching keyword [let suppose FIND_WORD(---------
-----------
-----------);
is terminating after 2 or 3 lines at " );" ]but i need to remove next few lines also till ");"
I am using
if ($line =~ m/FIND_WORD/) {return 0;}
which removes one line
I need to remove till ");"

Comment Responses

Anirudh Permalink
April 20, 2016, 06:24

# define a regex for matching balanced parens
my $re = qr/( [(]+ ) (.*?) (??{"\\)" x length $1})/xms;

while( defined(local $_ = <>) ) {
print, next unless /FIND_WORD/ && /$re/xms;
$_ .= <>;
redo;
}

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "browser_303": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.