sub pars0r{ foreach my $volume (@raw_data) { if ($volume =~ /$vol_to_parse/){ $counter++; # Set counter to one the first time } if ($counter <= 1){ # Changed ">= 1" to "<= 1" # This block executes after the first match, and up to # the next non-match, which is NOT what you want! ## print "$vol_to_parse got got \n"; } elsif( $counter > 1){ next; } } }