Eric Wilhelm wrote:
> I'm very troubled by any inclusion of underscores in the META.yml spec 
> because they behave differently between perl v-strings and version.pm.
> 
> Example:  v1.0.2_3 gt v1.0.3, but qv(v1.0.2_3) < v1.0.3

You aren't using version.pm comparisons in both cases, so it shouldn't be all
that surprising that it doesn't work the way you'd expect it.  Look here:

$ perl -Mversion -MDevel::Peek -e 'Dump(v1.0.2_3)'
SV = PVMG(0x830658c) at 0x82a8984
  REFCNT = 1
  FLAGS = (PADTMP,RMG,POK,READONLY,pPOK)
  IV = 0
  NV = 0
  PV = 0x82cacac "\1\0\27"\0
  CUR = 3
  LEN = 8
  MAGIC = 0x82caf24
    MG_VIRTUAL = 0
    MG_TYPE = PERL_MAGIC_vstring(V)
    MG_LEN = 8
    MG_PTR = 0x82cc464 "v1.0.2_3"

When constructing the PV, the underscore is ignored (as in any bare number), but
the PERL_MAGIC_vstring(V) has the original text as written.  If you do this 
instead:

$ perl -Mversion -e 'print (v1.0.2_3 < version->new(v1.0.3))'
1

you'll see that correct version object comparisons work as designed.  If your
code is comparing versions with version.pm, liberally sprinkle version->new() on
at least one of your terms and you will always be safe.  Don't use qv() because
it is _not_ a generic version object creator; it forces extended version
notation, even where it would otherwise parse as numeric:

>        ยท qv()
>            An alternate way to create a new version object is through the
>            exported qv() sub.  This is not strictly like other q? operators
>            (like qq, qw), in that the only delimiters supported are parenthe-
>            ses (or spaces).  It is the best way to initialize a short version
>            without triggering the floating point interpretation.  For example:
> 
>              $v1 = qv(1.2);         # 1.2.0
>              $v2 = qv("1.2");       # also 1.2.0
> 
>            As you can see, either a bare number or a quoted string can usually
>            be used interchangably, except in the case of a trailing zero,
>            which must be quoted to be converted properly.  For this reason, it
>            is strongly recommended that all initializers to qv() be quoted
>            strings instead of bare numbers.

This was one of my big failings when writing version.pm; I originally intended
this to be useful to CVS users (where $Revision$ is a sequence of integers
separated by one or more decimal points).  However, a lot of people assumed
because it was 'qv' (quoted version) that must mean it was a generic version
creation operator.

John

Reply via email to