Re: string comparison
- From: Gunnar Hjalmarsson <noreply@xxxxxxxxx>
- Date: Thu, 29 Sep 2005 19:19:21 +0200
Babacio wrote:
Shashank Khanvilkar <shashank@xxxxxxxxxxxxxxx> writes:How can i make the below program print "right choice".
$a = "apple";
if ($a eq ('apple'|'banana')){ print "right choice\n"; }else{ print "wrong choice\n"; }
But if I guess what you really want to do, try that :
if ($a eq 'apple' || $a eq 'banana') { etc }
or this:
if ( grep $a eq $_, ('apple', 'banana') ) {(perldoc -f grep)
And read some documentation,
Indeed.
-- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl .
- Follow-Ups:
- Re: string comparison
- From: Anno Siegel
- Re: string comparison
- References:
- string comparison
- From: Shashank Khanvilkar
- string comparison
- Prev by Date: Re: Order of Elements in Hash
- Next by Date: Re: Perl debugging
- Previous by thread: Re: string comparison
- Next by thread: Re: string comparison
- Index(es):