use strict; use Scalar::Util qw/looks_like_number/; sub equal { my ($first, $second) = @_; if ( (! defined $first and ! defined $second) or (looks_like_number($first) and looks_like_number($second) and $first == $second) or (defined $first and defined $second and $first eq $second) ) { return 1; } else { return 0; } } while () { my ($first, $second, $result) = split /,/; chomp $result; if ($result == equal($first, $second)) { print "OK: >$first< >$second< >$result<\n"; } else { print "NOT OK: >$first< >$second< expected >$result<; got >",equal($first, $second),"<\n"; } } __DATA__ undef,undef,1 undef,,0 undef,0,0 ,,1 100,100,1 100,99,0 100,0100,1 100,1E2,1 100,100.00,1 1000,1_000,1 1000,1_000.00,1 1000,1 000,1 1000,1 000.00,1 string,string,1 string,another_string,0