Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Eliminating Trailing Zerosby Lachesis (Friar) |
on Jul 17, 2003 at 14:36 UTC ( [id://275224]=note: print w/replies, xml ) | Need Help?? |
$n =~ s/\.?0+$//;
Update: Thanks to dreadpiratepeter for spotting my stupid mistake. The better option would be $n =~ s/\.\d*?0+$//; Update2: That worked with my test data but only because I wasn't using formatted strings so trailing 0s were already dealt with. Doh! With a %x.yf formatted string the original approach will work fine. jmcnamara came up with probably the best solution Re: Eliminating Trailing Zeros
In Section
Seekers of Perl Wisdom
|
|