Matching an array of strings to strings in a file.

Randal L. Schwartz merlyn at
Mon Aug 29 17:36:59 BST 2011

>>>>> "Gianni" == Gianni Ceccarelli <dakkar at> writes:

Gianni>     my $rx = join '|',map { "\Q$_\E" } @$strings;

No need for \E if you're already at the end of the string.

And I'd change that to just

  quotemeta $_

to make it clearer, and avoid the one layer of copying.

Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at> <URL:>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See for Smalltalk discussion

More information about the mailing list