Re: string comparison



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.
.



Relevant Pages

  • Re: Net::DNS
    ... function because you still use $rr within the foreach, ... > So I can find the all these object methods in the perl docs listed below? ... > the return value of 'grep'. ... > perldoc perlboot ...
    (perl.beginners)
  • Re: references to OTHER objects
    ... > please don't think i don't try, but it's the searchign where i lose. ... >> I understand that perldoc can be sometimes lacking (I'm sure patches are ... I used 'grep' much more than perldoc until I was ... Of course you can use perl to do the same task as someone else as ...
    (comp.lang.perl.misc)
  • Re: stat and its exceptions
    ... match the pattern, ... Please read perldoc perlstyle. ... It's not in the FAQs, ... > I know the grep loads everything. ...
    (comp.lang.perl.misc)
  • Re: "Escape" in perl
    ... Computers are much better at searching than using paper... ... I never actually use perldoc for searching the standard docs. ... that I can then grep it). ... my "Perl problem resolution checklist", ...
    (comp.lang.perl.misc)
  • Re: Net::DNS
    ... So I can find the all these object methods in the perl docs listed below? ... the return value of 'grep'. ... Loop over every value returned by calling 'answer' on $query, ... perldoc perlboot ...
    (perl.beginners)