On 9/5/06, Michael Alipio <[EMAIL PROTECTED]> wrote:
Hi,

Suppose I have the output of this command
date +%d.%H

which outputs:
06.11

I want to adjust the last two digits to less 1:
such that it becomes  06.10..
how do I do that?

perhaps something like this.
s/\d+$/(regexp being lookup minus 1/


thanks!


s/\.(\d+)$/$1-1/e

But as Adriano pointed out, a simple subtraction won't do what you
want. 6.00 will become 6.-1.

you could get around that by doing something like:

s/\.(\d+)/$1 > 0 ? $1-1 : 0/e

But that still probably won't do what you want, because 6.00 - 1
should really be 5.23 in most cases.

Your best bet is to look at a module like Date::Manip or Date::Calc.

also, there's no reason to run `date` as an external command. See
perl's built-in localtime() function.

HTH,

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.downloadsquad.com  http://www.engatiki.org

values of β will give rise to dom!

Reply via email to