Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Multiple Conditional Statements

by vsespb (Hermit)
on Sep 11, 2013 at 11:14 UTC ( #1053463=note: print w/ replies, xml ) Need Help??


in reply to Re: Multiple Conditional Statements
in thread Multiple Conditional Statements

There can be problem with string vs numeric comparison:

use v5.10; ( $RB1, $RB2, $WR1, $WR2, $TE1 ) = (1,2, 3, "05", 5); if( keys %{ { map{ $_,$_ } $RB1, $RB2, $WR1, $WR2, $TE1 } } == 5 ) { say 'all different'; } else { say 'some same' };; prints "all different"


Comment on Re^2: Multiple Conditional Statements
Download Code
Replies are listed 'Best First'.
Re^3: Multiple Conditional Statements
by BrowserUk (Pope) on Sep 11, 2013 at 11:21 UTC

    For strictly numeric comparison add 0+:

    if( keys %{ { map{ 0+$_,$_ } $RB1, $RB2, $WR1, $WR2, $TE1 } } == 5 ) { + say 'all different' } else { say 'some same' };;

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Yes, that would work.
Re^3: Multiple Conditional Statements
by BrowserUk (Pope) on Sep 11, 2013 at 11:18 UTC

    Indeed.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2015-09-04 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred temperature scale is:










    Results (137 votes), past polls