sub FormatValue { $c = 0; $vl = $_[0]; if ($vl ne "0,00" and $vl ne "0" and $vl ne ",00" and $vl ne ".0000") { if ($vl =~ m/(\.0000)/) { $vl =~ s/(\.0000)$/,00/; } else { $vl .= ",00"; } ($interessa,$zeros) = split (",",$vl); $compr = length $interessa; $c = int ($compr / 3); if ($c eq 1 and $compr > 3) { $um = substr($interessa, -3, 3); $interessa =~ s/$um/\.$um/; } elsif ($c eq 2) { $um = substr($interessa, -6, 3); $dois = substr($interessa, -3, 3); $interessa =~ s/$um/$um\./; } $result = $interessa.",".$zeros; } else { $result = "0,00"; } return $result; }