Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Eliminating Trailing Zeros

by dreadpiratepeter (Priest)
on Jul 17, 2003 at 14:29 UTC ( [id://275222]=note: print w/replies, xml ) Need Help??


in reply to Eliminating Trailing Zeros

$n =~ s/\.0*$|0*$//;
UPDATE: fixed lack of reading requirements


-pete
"Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."

Replies are listed 'Best First'.
Re: Re: Eliminating Trailing Zeros
by Trimbach (Curate) on Jul 17, 2003 at 14:37 UTC
    $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

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Re: Eliminating Trailing Zeros
by Anonymous Monk on Jul 17, 2003 at 14:40 UTC
    That is Perfect! Thanks!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-19 08:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found