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

RE: Comparing to many possibles

Thread Previous | Thread Next
From:
Wagner-David
Date:
March 4, 2002 09:56
Subject:
RE: Comparing to many possibles
Message ID:
113A7A0D1F47D511B92E00D0B7E03DAB0187BBBA@pmail02.vikingfreight.com
	Could use a regex:
		if ( $x =~ /[XYZ]/ ) {
		   # if contains
 		 }else
		   # if doesn't contain
		 }

	If there can be more than one character (like ' ABX') then you would need to add:

		$x =~ /^[XYZ]$/ 
	  Also XYZ could be replaced as X-Z in the character class.

Wags ;)
-----Original Message-----
From: wix@eskimo.com [mailto:wix@eskimo.com]
Sent: Monday, March 04, 2002 11:34
To: beginners@perl.org
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' )

TIA,
Dennis

-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About