sub numfix { my $num = shift; 1 while $num =~ s/^([-+]?\d+)(\d{3})/$1,$2/; $num = sprintf("%.2f", $num); return $num; }