Re: [OT] perl help on number modification

2010-01-19 Thread Ian Malone
2010/1/14 Dave Cross : > But I'd probably do something like this: > > > #!/usr/bin/perl > > use strict; > use warnings; > > foreach () { >  s/\.?0+$//; >  print; > } > > __END__ > 1.20 > 1.00 > 1.25 > > Not sure about the '?', surely you don't want this to happen: #!/usr/bin/perl use strict; us

Re: [OT] perl help on number modification

2010-01-19 Thread Gianluca Cecchi
On Tue, Jan 19, 2010 at 5:57 PM, Gianluca Cecchi wrote: > BTW also the second suggestion by Jake worked; it only was with more > typed characters > Thanks again > I missed Bruno suggestion too that was a simple substitution of + with * Now the credits are ok (hopefully): they are important

Re: [OT] perl help on number modification

2010-01-19 Thread Gianluca Cecchi
On Fri Jan 15 23:04:38 UTC 2010, Bill Davidsen wrote: > Does that do what you want? I would think that you want "1." to become just > "1" > as well. > > In perl: perl -e 'while(<>) { s/[.0]+$//; print "$_\n" }' Ok Bill, this is unlikely to happen, as I get values from another application and in c

Re: [OT] perl help on number modification

2010-01-15 Thread Bill Davidsen
Gianluca Cecchi wrote: > On Thu, Jan 14, 2010 at 11:10 AM, Gianluca Cecchi > 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 i

Re: [OT] perl help on number modification

2010-01-15 Thread Bruno Wolff III
On Thu, Jan 14, 2010 at 10:24:35 +, Dave Cross wrote: > s/\.?0+$//; While it wasn't covered explicitly in the examples I suspect that a lone trailing decimal point should also be stripped so that the pattern should be: s/\.?0*$//; -- users mailing list users@lists.fedoraproject.org To un

Re: [OT] perl help on number modification

2010-01-15 Thread Jake Peavy
On Fri, Jan 15, 2010 at 5:01 AM, Gianluca Cecchi wrote: > On Thu, Jan 14, 2010 at 11:10 AM, Gianluca Cecchi > 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

Re: [OT] perl help on number modification

2010-01-15 Thread Gianluca Cecchi
On Thu, Jan 14, 2010 at 11:10 AM, Gianluca Cecchi 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 as

Re: [OT] perl help on number modification

2010-01-14 Thread Jake Peavy
On Thu, Jan 14, 2010 at 5:10 AM, Gianluca Cecchi 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 subt

Re: [OT] perl help on number modification

2010-01-14 Thread Dave Cross
2010/1/14 Gianluca Cecchi : > 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 in

[OT] perl help on number modification

2010-01-14 Thread Gianluca Cecchi
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