[Rd] Perl question

Duncan Murdoch murdoch@stats.uwo.ca
Fri Feb 21 20:50:49 2003


I'm working on the installer code, but I don't know Perl well enough.
What is a good Perl equivalent of the R statement

 if ( s %in% c('string1', 'string2', 'string3') )  ...

I can do it with 

 if (s == "string1" || s == "string2" || s == "string3")  ...

but I've got a feeling there's a better way to do it using associative
arrays.  

The real example will have about a dozen fixed strings that I want to
search a few thousand times.

Duncan Murdoch