in reply to Re^2: how to remove block of data from file based on string
in thread how to remove block of data from file based on string

Here is your solution:
my $str = <<'EOB'; start hehu7 gjwsdh hsjdhj remove hjhsj jdkwj hwjdhjwh end start crgr hjdhwjd wjdkwj wkjw g hjhd end EOB while ($str =~ /(\bstart\b.*?\bend\b\s*)/gs) { my $block = $1; if ($block =~ /\bremove\b/) { $str =~ s/\Q$block\E//; } } print $str; __END__ start crgr hjdhwjd wjdkwj wkjw g hjhd end

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.