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"; } } #### my $section = 0; my @sectone; my @secttwo; while() { if (/;section([12])/) { push( $1 == 1? @sectionone : @sectiontwo, $_); } else { print "No section defined for: $_\n"; } } #### my $section = 0; my %sections = (1 =>[],2=>[]); while() { if (/;section([12])/) { push @{$sections{$1}},$_; } else { print "No section defined for: $_\n"; } } #### my $section = 0; my %sections = (1 =>[],2=>[]); while() { push @{$sections{$1}},$_ and next if /;section([12])/; warn "No section defined for: $_\n"; # cause warn gives you $. in } #### my $section = 0; my @sectone; my @secttwo; while() { if (/;section([12])/) { $section = ( $1 == 1 ? @sectionone : @sectiontwo); } else { push @{$section},$_ and next if $section; warn "No section defined for: $_\n"; } } #### my $section = 0; my %sections = (1 =>[],2=>[]); while() { if (/;section([12])/) { $section = $1 and next } push @{$sections{$section|| warn "No section defined for: $_\n" and next()}} ,$_; } #### 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}},$_ } #### my $section = 0; my %sections = (1 =>[],2=>[]); while() { push @{$sections{( /;section([12])/ and $section = $1 and next() ) or ( $section || warn "No section defined for: $_\n" and next() )}} ,$_; }