in reply to Re: When is 111111 greater than 0222222?
in thread When is 111111 greater than 0222222?

I knew there'd be an obvious explanation. Thank you so much. Where is that documented, by the way?

Note for other monks, if you invent a file-naming system based on dates, use '2003' instead of '03' at the start and you won't have this problem. D'oh!



“Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.”
M-J D
  • Comment on Re: Re: When is 111111 greater than 0222222?

Replies are listed 'Best First'.
Re: Re: Re: When is 111111 greater than 0222222?
by PodMaster (Abbot) on Jun 30, 2003 at 06:27 UTC
      Thanks PodMaster.



      “Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.”
      M-J D
Re: Re: Re: When is 111111 greater than 0222222?
by The Mad Hatter (Priest) on Jun 30, 2003 at 05:41 UTC
    I'm not sure where it is formally documented, but it is in a perlfaq4 question: perldoc -q octal. The prepending of 0 comes from C (IIRC), but it might have originated earlier. BTW, 0x is used to specify hex values.

    Heh. You should always use full dates anyway. ; )

Re: When is 111111 greater than 0222222?
by Abigail-II (Bishop) on Jun 30, 2003 at 11:49 UTC
    It's documented in the perldata manual page, in the section Scalar value constructors.

    Abigail

Re: When is 111111 greater than 0222222?
by cLive ;-) (Prior) on Jun 30, 2003 at 16:58 UTC
    ...if you invent a file-naming system based on dates, use '2003' instead of '03' at the start...

    Or even, find out about ISO date formats, particularly the "Complete date" format!

    .02

    cLive ;-)

Re: Re: Re: When is 111111 greater than 0222222?
by Jasper (Chaplain) on Jun 30, 2003 at 11:09 UTC
    There was a little thing a couple of years ago - you might have heard of it - called 'the millennium bug'.

    Jasper
      I should say, in my defense, that this code will never have to deal with dates before '01, and unless something truly bizarre happens, won't even have to deal with dates after '05. I won't have problems until 2010.

      I know that's exactly what millennium bug people thought, but seriously, an SQL database is coming long before it would be an issue, with proper dates. If all else fails I'll mass-rename and rewrite a couple of subs and all will be well again.

      Can I use this space to ask what happens to my unfortunately-constructed numbers in the following circumstances:

      1. $number = '022222'
      2. $number = "022222"
      3. $number = 022222
      4. @numbers = READDIR(something); $number = $numbers[0] # assuming my file's called '022222'
      ?

      “Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.”
      M-J D
        1. Used in numerical context, $number == 22222
        2. Used in numerical context, $number == 22222
        3. Used in numerical context, $number == 9362 (in base 10, 22222 in octal (base 8))
        4. Used in numerical context, $number == 22222 (I think)
        Is that what you want? Or did I misunderstand your questions?