my $thing; foreach (@array) { my ($num,$value) = split /,/; if ($num == 1006) { $thing=$value; last; } }