Skip to content

Perl question

1 message · Dirk Eddelbuettel

#
You probably wanted 'eq' instead of '=='.  The reg.exp. version is

    if (s =~ m/(string1|string2|string3)/o) {  ...

where the trailing o makes it supposedly less expensive (regexp 
only compiled once, see man perlop).
You could use grep and map on assoc. arrays, but IMHO the above is easier.
That may be worth profiling / timing.

Dirk