Adam Kennedy wrote:

Yes, the point i was making is that it should treat '0.23_04' as 0.2304.

Actually, that would be wrong. Perl version already have a mapping system.

0.2304 would be 0.230.400, or shorthand, 0.23.4

Underscores are not part of that.

No that's not correct; you do not ignore trailing zeros when writing the "extended" notation. You _are_ correct that a bare number with an underscore is tokenized as if it had only numbers, but the version object handling is more sophisticated than that.

For example:

perl -MDwevel::Peek -Mversion -le \
'$v = version->new("0.23_04"); print$v; Dump $v;'
0.23_0400
SV = PV(0x8171ba8) at 0x8170cdc
  REFCNT = 1
  FLAGS = (ROK,OVERLOAD)
  RV = 0x8170d00
  SV = PVHV(0x8175760) at 0x8170d00
    REFCNT = 1
    FLAGS = (OBJECT,SHAREKEYS)
    IV = 3
    NV = 0
    STASH = 0x81b4750   "version"
    ARRAY = 0x8198ab8  (1:1, 2:1)
    hash quality = 90.0%
    KEYS = 3
    FILL = 2
    MAX = 1
    RITER = 0
    EITER = 0x0
    Elt "width" HASH = 0x96beeca0
    SV = IV(0x818f378) at 0x81db5b8
      REFCNT = 1
      FLAGS = (IOK,pIOK)
      IV = 2
    Elt "alpha" HASH = 0x2db8d1aa
    SV = IV(0x818f164) at 0x81f4804
      REFCNT = 1
      FLAGS = (IOK,pIOK)
      IV = 1
    Elt "version" HASH = 0x68c27e33
    SV = RV(0x819b86c) at 0x81db5a0
      REFCNT = 1
      FLAGS = (ROK)
      RV = 0x8170b44
      SV = PVAV(0x8175c64) at 0x8170b44
        REFCNT = 1
        FLAGS = ()
        IV = 0
        NV = 0
        ARRAY = 0x818a438
        FILL = 2
        MAX = 3
        ARYLEN = 0x0
        FLAGS = (REAL)
        Elt No. 0
        SV = IV(0x818f37c) at 0x81f4834
          REFCNT = 1
          FLAGS = (IOK,pIOK)
          IV = 0
        Elt No. 1
        SV = IV(0x818f380) at 0x81f4840
          REFCNT = 1
          FLAGS = (IOK,pIOK)
          IV = 230
        Elt No. 2
        SV = IV(0x818f384) at 0x81db5c4
          REFCNT = 1
          FLAGS = (IOK,pIOK)
          IV = 400
  PV = 0x8170d00 ""
  CUR = 0
  LEN = 0

Note that the version object is (more or less) 0.230.400, but that it keeps track of the fact that this was an alpha version (underscore) as well as the original width (2), so that on output the underscore can be reinserted at the proper place (the trailing zeros are mathematically insignificant).

John

--
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Boulevard
Suite H
Lanham, MD  20706
301-459-3366 x.5010
fax 301-429-5748

Reply via email to