sub fuzz { my $n = shift(); return unless defined($n); my $neg = ($n < 0); ($n) = ($n =~ /(\d+)/); $n += 0; my ($c1, $c2) = ($n =~ /^(\d{0,2}\d{3})((?:\d{3})*)$/); return $neg ? -$n : $n unless defined($c1); my $c3 = substr($c1, -3, 2, ""); my $c4 = substr($c1, -1, 1, ""); my $n2 = $c1 . $c3; my $x1 = 100 - $c3; my $x2 = (10 - $c3 % 10) % 10; $n2 += $c1 ? ( ($x1 <= 30 && $c1 >= 10) ? $x1 : $x2 ? $x2 : $c4 ? 1 : 0 ) : ($c4 ? 1 : 0); $n2 .= 0 x (length($c2) + 1); return $neg ? -$n2 : $n2; }