http://www.perlmonks.org?node_id=1053470


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

Same problem with your example and with uniq() - string vs numeric comparison. Can be worked around by numifying data:
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,2,3,"05",5 ), 0 , "some duplicates with different + string"); is( all_different( map { $_+0 } 1,2,3,"05",5 ), 0 , "some duplicates w +ith different strings numified"); is( all_different( 1,1,3,4,5 ), 0 , "some duplicates"); is( all_different(), 1 , "empty paramlist"); done_testing;
result:
ok 1 - all different not ok 2 - some duplicates with different string # Failed test 'some duplicates with different string' # at 3.pl line 17. # got: '1' # expected: '0' ok 3 - some duplicates with different strings numified ok 4 - some duplicates ok 5 - empty paramlist 1..5