my $section = 0; my @sectone; my @secttwo; while() { if (/;section(1)/) { push(@sectionone, $_); } elsif (/;section(2)/) { push(@sectiontwo, $_); } else { print "No section defined for: $_\n"; } }