How about using a hash?:
use strict ;
my $x;
my %wanted ;
foreach (qw( word1 word2 whatever this that the-other) ){
$wanted{$_}= 1;
} ;
$x = 'the-other' ;
if( $wanted{$x} ){
print "found $x\n" ;
}
else{
print "can't find $x\n" ;
} ;
$x = 'no-go' ;
if( $wanted{$x} ){
print "found $x\n" ;
}
else{
print "can't find $x\n" ;
} ;
which produces:
---------- Capture Output ----------
"C:\Perl\bin\perl.exe" test.pl
found the-other
can't find no-go
Terminated with exit code 0
On Wed, 02 Mar 2005 23:21:50 -0500, Chris Wagner <[EMAIL PROTECTED]> wrote:
> I think ur first way was the best way. It all depends on what the
> comparison is. If it's simple, use or's, but if it gets long and
> complicated then it's worth it to use regex. Better to do one or two XOR's
> than load up the regex engine. But of course u won't notice any difference
> unless ur doing a few dozen thousand of em.
>
> At 08:51 PM 3/2/05 -0500, Paul Rogers wrote:
> >----- Original Message -----
> >From: "$Bill Luebkert" <[EMAIL PROTECTED]>
> >> if ($x =~ /^(word1|word2|word3|word4)$/) {
> >
> >Aha! Yes...this will do it for sure.
> >
> >Thanks :-)
> >Paul ---
>
> --
> REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=--
> "...ne cede males"
>
> 00000100
>
> _______________________________________________
> Perl-Win32-Users mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs