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

      So use \z if it make you happy - it all depends upon your context. I didn't bother cause I knew someone to rise to the bait {grin}. I can be an important point (usually it is not) so it deserves reiteration.

      cheers

      tachyon

      s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print