Re: [OT] perl help on number modification

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 14, 2010 at 11:10 AM, Gianluca Cecchi
<gianluca.cecchi@xxxxxxxxx> wrote:
> Todo:
> 1.20 must become 1.2
> 1.00 must become 1
> 1.25 must remain the same

Thanks to Dave, Jake and Geoffrey even if my answer was OT... thanks
also for the perl links

For Jake:
the problem is that in your example I think that perl assumes they are
numbers and renders them correspondingly. In my case, I get them as
strings during the workflow, so that perl doesn't manage
automatically...
For example:
perl -le '$foo=1.00; print $foo'
1
[gcecchi@tekkaman ~]$ perl -le '$foo="1.00"; print $foo'
1.00

BTW, it was the correct regex that I missed. Simple to read after you
pointed out, but (at least for me) difficult to catch initially... ;-)
Actually I had to make the job in awk where I then easily got the same
effect with:
sub(/\.?0+$/, "", foo)

Thanks again and hope to repay in some way ...
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe: https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux