Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Re: Eliminating Trailing Zeros

by Trimbach (Curate)
on Jul 17, 2003 at 14:37 UTC ( #275226=note: print w/ replies, xml ) Need Help??


in reply to Re: Eliminating Trailing Zeros
in thread Eliminating Trailing Zeros

$n=~s/\.|\.0+$//
That's broken. It deletes the period but leaves in the trailing zeros. This is better, and does what's requested:
s/\.?0*$//;

Gary Blackburn
Trained Killer


Comment on Re: Re: Eliminating Trailing Zeros
Download Code
Re: Re: Re: Eliminating Trailing Zeros
by dreadpiratepeter (Priest) on Jul 17, 2003 at 14:40 UTC
    That turns 42000 into 42

    -pete
    "Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."
      Yup, but $n=sprintf("%2.4f",$n); will always return a number with a decimal, so that's not an issue.

      Gary Blackburn
      Trained Killer

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://275226]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2015-07-04 15:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls