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