in reply to Is there a way of storing 600 in a scalar as 0600 (24 hour clock style)?

The above answers are adequate, but I'd like to add that all you have to do is treat the 600 like a string instead of a number. So if you wanted to make a "24 hour" variable, all you'd have to do is something like;
$time = 600; ($time = "0".$time) if ($time < 1000);
  • Comment on Re: Is there a way of storing 600 in a scalar as 0600 (24 hour clock style)?
  • Download Code

Replies are listed 'Best First'.
Re: Answer: Is there a way of storing 600 in a scalar as 0600 (24 hour clock style)?
by I0 (Priest) on Dec 26, 2000 at 06:39 UTC
    what if $time < 100?
Re: Answer: Is there a way of storing 600 in a scalar as 0600 (24 hour clock style)?
by eg (Friar) on Dec 26, 2000 at 21:50 UTC

    Heh. Then, I suppose, the code becomes:

    $time = 600; ($time = "0".$time) if ($time < 1000); ($time = "0".$time) if ($time < 100); ($time = "0".$time) if ($time < 10);

    p.s. Don't do this -- stick with sprintf