[OT] perl help on number modification

Jake Peavy djstunks at gmail.com
Thu Jan 14 19:42:09 UTC 2010


On Thu, Jan 14, 2010 at 5:10 AM, Gianluca Cecchi
<gianluca.cecchi at gmail.com>wrote:

> Hello,
> any hint on trasforming with perl a number using only one substitute
> function for reg exp?
> Todo:
> 1.20 must become 1.2
> 1.00 must become 1
> 1.25 must remain the same
>
> So that if after the dot are all zeros, I have to subtitute with
> corresponding integer, and in general I have to remove trailing zeros
> for decimal numbers.
>

I'm not sure what you're talking about.  If I understand the question, Perl
does it already.  DWIM, eh wot?

C:\>perl -le "print for 1.20, 1.00, 1.25"
1.2
1
1.25

PS: please pardon the C:\ ;-)

-- 
-jp

He was the kind of man who was not ashamed to show affection. I guess that's
what I hated about him.

deepthoughtsbyjackhandey.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fedoraproject.org/pipermail/users/attachments/20100114/61462298/attachment.html 


More information about the users mailing list