sub pars0r{ foreach my $volume (@raw_data) { if ($volume =~ /$vol_to_parse/) { my $counter++; # Create new $counter, set it to 1 if($counter <= 1){ # This will always be true print "$vol_to_parse got got \n"; } elsif ($counter > 1 ) { # Block will never be executed next; # or break; ? } } } }