in reply to Search after match in dynamic lines
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?
|
|---|