in reply to OR operator
In addition to the above you can use a RE perlre and do:
if ( $color =~ m/^(red|green|blue)$/ ) { blah }; # a common perl idiom is: my @colors = qw( red green blue pink fuscia ); my $color_re = join '|', @colors; $color_re = qr/$color_re/; # compile RE for efficiency if ( $color =~ m/^(?:$color_re)$/ ) { blah }
Note the ?: stops capturing the color matched in the RE in $1
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Re: OR operator
by merlyn (Sage) on Apr 10, 2003 at 01:10 UTC | |
by tachyon (Chancellor) on Apr 10, 2003 at 01:13 UTC |