Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: Re: Re: Re: OR operator

by DrManhattan (Chaplain)
on Apr 10, 2003 at 17:13 UTC ( [id://249685]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Re: OR operator
in thread OR operator

I think we're actually on the same page here. In my mind, $color is "this thing" and $_ is e.g. "blue". The code asks, "Is $color red", "Is $color green", or "Is $color blue?" To me, $_ eq $color reads, "Is red $color", "Is blue $color", or "Is green $color?" which seems backwards.

-Matt

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: OR operator
by Juerd (Abbot) on Apr 10, 2003 at 18:18 UTC

    I think we're actually on the same page here. In my mind, $color is "this thing" and $_ is e.g. "blue".

    But "for" topicalizes. $_ is the topic. $_ is more variable than $color, $_ is the thing.

    for (qw/green blue red/) { if ($color eq $_) { ... } } for each of green, blue and red: if the color is it, do something

    for (qw/green blue red/) { if ($_ eq $color) { ... } } for each of green, blue and red: if it is the color, do something

    I read $_ as "the thing" or "it". How do you read $_?

    Juerd
    - http://juerd.nl/
    - spamcollector_perlmonks@juerd.nl (do not use).
    

      I read $_ as "the thing" or "it". How do you read $_?

      The original poster wanted this:

      if ($color eq "blue || $color eq "red" || $color eq "green")
      My second post essentially stated ...
      if ($color eq $_)
      ... and dynamically replaced $_ with "blue", "red", or "green". Thus to me, $_ eq $color is like stating ...
      if ("blue eq $color || "red" eq $color || "green" eq $color)
      ... which isn't intuitive.

      -Matt

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://249685]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 05:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found