sub pars0r{ foreach my $volume (@raw_data) { if ($volume =~ /$vol_to_parse/) { my $counter++; if($counter <=1){ print "$vol_to_parse got got \n"; } elsif ( $counter > 1 ) { next; # or break; ? } } } }