One way is to keep a flag variable that keeps track of your state:
use warnings; use strict; my $in_section=0; while (my $line = <>) { chomp $line; if ( $line =~ /^Success.*Id-9952895b108957daeb296ba4/i ) { print "$line\n"; $in_section = 1; } elsif ( $line =~/^Success/ ) { $in_section = 0; } elsif ($in_section) { print "$line\n"; } }
Update now that you've formatted your post with <code> tags: Do these Success sections always have blank lines in between them, with no blank lines in the sections themselves?
In reply to Re: Search after match in dynamic lines
by haukex
in thread Search after match in dynamic lines
by leoberbert
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |