develooper Front page | perl.beginners | Postings from March 2002

RE: Comparing to many possibles

Thread Previous | Thread Next
Jason Larson
March 4, 2002 10:06
RE: Comparing to many possibles
Message ID:
> -----Original Message-----
> From: []
> Subject: Comparing to many possibles
> Greetings;
> Is there some perl shorthand that will make it easier to say
> 	if ( $x eq 'X' || $x eq 'Y' || $x eq 'Z' )

This should do what you want:
     if ($x =~ /^[XYZ]$/)

Hope this helps...



The information contained in this ELECTRONIC MAIL transmission
is confidential.  It may also be privileged work product or proprietary
information. This information is intended for the exclusive use of the
addressee(s).  If you are not the intended recipient, you are hereby
notified that any use, disclosure, dissemination, distribution [other
than to the addressee(s)], copying or taking of any action because
of this information is strictly prohibited.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About