Matching an array of strings to strings in a file.
Randal L. Schwartz
merlyn at stonehenge.com
Mon Aug 29 17:36:59 BST 2011
>>>>> "Gianni" == Gianni Ceccarelli <dakkar at thenautilus.net> 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 stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion
More information about the london.pm
mailing list