#!/usr/bin/perl my $value = .23456; my $formatted = sprintf("%.3f", $value); $formatted =~ s/([^0-9])0\./$1./; print "$value => $formatted\n"; $value = $formatted = -.23456; $formatted = sprintf("%.3f", $value); $formatted =~ s/([^0-9])0\./$1./; print "$value => $formatted\n";