[Chicago-talk] isolating the values to right and left of the decimal

Ted Zlatanov tzz at lifelogs.com
Wed Jan 9 13:52:59 PST 2008


On Wed, 9 Jan 2008 13:01:43 -0800 (PST) tiger peng <tigerpeng2001 at yahoo.com> wrote: 

tp> Here is my solution for fun:
tp> perl -e '$t=13.32; $t =~ s/(\d+)(\.\d+)/$1.":". (int $2*60 + .5<10?"0":"").int $2*60 + .5/e; print "$t\n"'

I think this is a little cleaner as a one-liner and will work with 
$t = .32 for example:

perl -e'$t = 13.32; printf "%d:%d\n", $t, ($t*60)%60;'

Ted


More information about the Chicago-talk mailing list