in reply to Getting element of array with a match
or even:my $thing; foreach (@array) { if (/^1006,(.*)/) { $thing=$1; last; } }
BTW, your code above won't work because grep returns the number of matches in scalar context.my $thing; foreach (@array) { my ($num,$value) = split /,/; if ($num == 1006) { $thing=$value; last; } }
|
---|