use strict; use warnings; use diagnostics; sub isequal { return 0 if ( grep { ! defined( $_ ) } @_ ) != scalar @_; no warnings qw/uninitialized/; my %gadget; @gadget{ @_ } = (); return scalar keys %gadget == 1 ? 1 : 0; } my @test = ( [ 0, 1 ], [ "1", "one" ], [ 0, "0" ], [ 0, undef ], [ 1, undef ], [ "hello", undef ], [ undef, undef ], [ 1, 1 ], [ "1", 1 ], [ "hello", "hello" ] ); foreach my $items ( @test ) { my( $left, $right ) = @{ $items }; my $comp = isequal( $left, $right ); foreach( $left, $right ) { ! defined $_ and $_ = "undef"; } print "Testing $left, $right == ", $comp ? "equal\n" : "not equal\n"; }