my $Como; foreach my $i (0..$#Comment) { $Como = $Comment[$i], last if $Comm[$i] == $value; } # ... and you should add error-checking: unless (defined $Como) { # do something here if we didn't find anything }