in reply to grep with multiple choice
should be enough. There's nothing particularly different with this "grep with multiple choice". The only thing it seems you are missing is that the grep block can match different values provided you code a suitable matching sub, like I did with a regex. If your problem is really to find out the array elements starting with $s, this will work:grep { /^Julia_Roberts/ } @arr
grep { /^\Q$s\E/ } @arr; # regex with quoted interpolation # or grep { index $_, $s == 0 } @arr; # more efficient
|
---|
In Section
Seekers of Perl Wisdom