Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

You should introduce a test function instead of listing all combinations in the if clause. I read your condition as no duplicates allowed, so this should work:

use strict; use warnings; use Test::More; sub all_different { my %seen; for ( @_ ) { return 0 if $seen{$_}++; } #-- duplicate found return 1; } # e.g. if ( all_different($RB1, $RB2, $WR1, $WR2, $TE1) ) { ... is( all_different( 1,2,3,4,5 ), 1 , "all different"); is( all_different( 1,1,3,4,5 ), 0 , "some duplicates"); is( all_different(), 1 , "empty paramlist"); done_testing;

Perhaps you can also use uniq() from List::MoreUtils?

Update: In response to vsespb's comment below - the OP didn't specify if e.g. 05.0 is identical to 5 or not - probably yes, so numification is advised. However, as shown below, sanitizing input or creating a specialised all_different_nums() sub can be done by the OP if necessary. Only the OP knows, what is equal in his/her given context. I.e., floats might need normalisation using sprintf... we don't know (yet).

Maybe this one is more robust?

use strict; use warnings; use Scalar::Util qw(looks_like_number); use Test::More; sub all_different { my %seen; for ( @_ ) { my $norm_val = looks_like_number( $_ ) ? 0+$_ : $_; return 0 if $seen{$norm_val}++; #-- duplicate found } return 1; } # e.g. if ( all_different($RB1, $RB2, $WR1, $WR2, $TE1) ) { ... is( all_different( 1,2,3,4,5 ), 1 , "all different (num)"); is( all_different( 1,1,3,4,5 ), 0 , "some duplicates (num)"); is( all_different( qw(a b 8) ), 1 , "all different (str)"); is( all_different( qw(a a 8) ), 0 , "some duplicates (str)"); is( all_different( qw(5 05.0 8) ), 0 , "some duplicates (mixed)"); is( all_different(), 1 , "empty paramlist"); done_testing;

In reply to Re: Multiple Conditional Statements by Perlbotics
in thread Multiple Conditional Statements by jdlev

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (5)
    As of 2018-05-24 20:44 GMT
    Find Nodes?
      Voting Booth?