Skip to content
Back to formatted view

Raw Message

Message-ID: <e30d5voq9g2pb71vqqeqk1ev05jb9os5i0@4ax.com>
Date: 2003-02-21T20:50:49Z
From: Duncan Murdoch
Subject: Perl question

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