in reply to Re^4: Getting lines in a file between two patterns
in thread Getting lines in a file between two patterns
Push lines to an array, clear it at each START.
poj#!/usr/bin/perl use strict; my $flag = 0; my @lines = (); while (<DATA>){ if (/^\s*END/){ $flag = 0 } elsif (/^\s*START/){ $flag = 1; @lines = (); } elsif ($flag) { push @lines,$_; } } print join '',@lines;
In Section
Seekers of Perl Wisdom