map {s#|#\\|#s; $_} @results
I hope you don't have any other uses for @results as you've modified it in-place.
Perl doesn't have a great idiom for this. This type of mistake and several others are so common that I really think Perl should have a 'filter' keyword.
And thanks(++) for bringing up the important point about escaping regular expression metacharacters and prompting diotalevi's reply (which is what I'd use).
- tyeIn reply to Re^2: Creating regex from arrays (oops)
by tye
in thread Creating regex from arrays
by debiandude
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |