#!/usr/bin/perl use strict; use warnings; while( my $nr = ){ 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