in reply to v1.2.3 syntax (vector of ordinals)

Exporter::require_version almost never gets called. See (tye)Re: Overriding Exporter::import.

I found it funny (and a little sad) that perldata.pod defines this new type of literal but avoids giving it a name. The 5.6.0 pods don't ever mention "v-string" but do eventually refer to these as "vectors of (ordinals|integers)".

As best as I can tell, there is absolutely no way to distinguish v53.46.52 from "5.4" once perl has parsed it. You could cheat a little and assume that if the version scalar already has a numeric value cached inside of it, then it probably isn't a ordinal vector.

You can use Devel::Peek to determine this or use the old hack:

my $version= shift; if( "0" eq ( $version ^ $version ) ) { # $version already has a numeric value } else { # $version is _only_ a string }

Checking the code in universal.c, I see that the default method does something similar:

if (!SvNIOK(sv) && SvPOK(sv)) { # ... } /* if we get here, we're looking for a numeric comparison,

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: v1.2.3 syntax
by John M. Dlugosz (Monsignor) on Jul 19, 2001 at 18:55 UTC
    The perldata that comes with ActiveState's latest build does not contain the string "vector". Perhaps the bleeding edge docs have already been improved?

    I guess I'll just have to assume that you'll never import a symbol with an illegal identifier name, and nobody will ask for a major version greater than 32 when I'm supporting a 1 or 2.

    Also, I don't beleive that the existing Exporter handles a v-string in $VERSION.

    —John