Stolen from The Daily WTF.
//return whether a double is negative bool IsNegative(double n) { string nStr = n.ToString(); if (nstr.IndexOf('-', 0, 1)) return true; return false; }
Crazy as it may seem, it seems about the simplest way to partition negative zero with all the other negative numbers. But I doubt that the original author had that in mind
my @comp_fields = qw(field1 field2 etc.);
...
if (is_crap(\%old_rec, \%this_rec, @comp_fields) {
...delete the records
}
...
sub is_crap {
my $rec1 = shift;
my $rec2 = shift;
for my $field (@_) {
return unless "-$rec1->{$field}" eq $rec2->{$field};
}
1;
}