6 Einträge, 1 Seite |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#!/usr/bin/perl use strict; use warnings; while( my $nr = <DATA> ){ chomp $nr; my $new = $nr; if( int($nr) == $nr ){ $new = int($nr); } else{ $new =~ s/(\.\d*?)?0+$/$1/; } print "$nr -> $new\n"; } __DATA__ 1.234000 2.01 9.00000 8.0 0.2340000 0.0 6.000001
my $new = 1 * $nr;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/usr/bin/perl -w use strict; while (<DATA>) { printf('%00g', $number); print "\n"; } __DATA__ 1.234000 2.01 9.00000 8.0 0.2340000 0.0 6.000001
6 Einträge, 1 Seite |