The thing that bugs me most about that snippet is the match-chomp-split sequence. I prefer:
my $id = 1006; my $answer; for (@data) { last if ($answer) = /^\Q$id\E\s*,(.*)/o; }
— Arien
Update: Added /o and allowed for optional whitespace between id and comma per tachyon's worries below.
In reply to Re: Re: Getting element of array with a match
by Arien
in thread Getting element of array with a match
by peppiv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |