Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Help with this statement

by tradez (Pilgrim)
on Jan 11, 2002 at 20:48 UTC ( #138047=note: print w/replies, xml ) Need Help??


in reply to Help with this statement

I believe your problem is the non-transative nature of the perl || and 'or' operators. in this case you are asking if it is equal to 456 or just 453. 453 of course is never 0 and therefore will be true. Hence printing something. to fix this just add.
if ($value == 456 || $value == 453){ print something; } else { print nothing; }
That should clear things up.

Replies are listed 'Best First'.
(cLive ;-) Re: Help with this statement
by cLive ;-) (Prior) on Jan 11, 2002 at 23:20 UTC
    I couldn't resist this as a TIMTOWTDI :)
    unless (abs($value - 454.5) - 1.5) { print something; } else { print nothing; }

    cLive ;-)

      just as an alternative, it can also be written as:
      my $value = 444; if ($value == 456) { print "something"; } elsif ($value == 453) { print "something"; } else { print "nothing"; }
Re: Re: Help with this statement
by basicdez (Pilgrim) on Jan 11, 2002 at 20:59 UTC
    Thanks I got it working now. peace dez L

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2022-05-27 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (94 votes). Check out past polls.

    Notices?