Re: string comparison
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxxx (Anno Siegel)
- Date: 30 Sep 2005 11:48:25 GMT
Gunnar Hjalmarsson <noreply@xxxxxxxxx> wrote in comp.lang.perl.misc:
> 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)
....or use Quantum::Superposition
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
.
- Follow-Ups:
- Re: string comparison
- From: Tassilo v. Parseval
- Re: string comparison
- References:
- string comparison
- From: Shashank Khanvilkar
- Re: string comparison
- From: Gunnar Hjalmarsson
- string comparison
- Prev by Date: Re: protect calling files directly?
- Next by Date: Re: string matching specific number of times
- Previous by thread: Re: string comparison
- Next by thread: Re: string comparison
- Index(es):
Relevant Pages
|