Thread Überflüssige Nullen hinterm Komma
(5 answers)
Opened by Gast at 2009-01-26 14:56 Code (perl): (dl
)
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 OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/) -- Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html Perl-Entwicklung: http://perl-services.de/ |