Trailing non-digits are fine - Perl will ignore them when
converting strings to numbers (not just Perl, atoi() and
friends allow that too). And if a newline is following the
number, Perl won't even emit a warning:
#!/usr/bin/perl
use strict;
use warnings;
my @array;
my $number = "3\n";
push @array, sprintf "%.5f", "$number\n";
print $array [0], "\n";
__END__
3.00000