#!/usr/bin/perl use strict; use warnings; while (<DATA>) { if ((my $first = /^\s*#if/) .. (my $last = /^\s*#endif/)) { #print if $first || $last; print unless /^\s*reports?/; } else { print; } }
Its a neat use of the range, ( .. ), operator.
Chris
Update: changed the first print line to more accurately perform what you needed.
In reply to Re^5: text matching
by Cristoforo
in thread text matching
by prassi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |