This uses the range operator:
use strict; use warnings; my $head_re = qr/^(?:Heading Here|Another Heading):/; my $end_re = qr/^End of section:/; while (<DATA>) { state $saw = 0; if (my $seq = /$head_re/ ... /$head_re|$end_re/) { if ($seq == 1) { s/^/\n/ unless $saw++; } elsif ($seq =~ /E0$/) { $saw = 0 if /$end_re/; redo; } else { s/^/ /; } } print; }
In reply to Re: Regexp help
by Anonymous Monk
in thread Regexp help
by thewebsi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |