my $section = 0; my %sections = (1 =>[],2=>[]); while() { if (/;section([12])/) { push @{$sections{$1}},$_; } else { print "No section defined for: $_\n"; } }