in reply to version string oddities

For the skinny on version strings, including their deprecation from the forthcoming 5.10 onwards, see the heading Version Strings in perldata.

To clear up the confusion about your third example, try adding -w.

C:\DELL\v>perl -wle"print -64.0.0.1" Argument "@\0\0^A" isn't numeric in negation (-) at -e line 1. 0

However, I can't come up with an explanation for the difference in treatment of your fourth example and similar. Only observe that no warning is emitted for upper or lower case alpha characters?

C:\DELL\v>perl -wle"print -64.0.0.1" Argument "@\0\0^A" isn't numeric in negation (-) at -e line 1. 0 C:\DELL\v>perl -wle"print -65.0.0.1" -A ☺ C:\DELL\v>perl -wle"print -90.0.0.1" -Z ☺ C:\DELL\v>perl -wle"print -91.0.0.1" Argument "[\0\0^A" isn't numeric in negation (-) at -e line 1. 0 C:\DELL\v>perl -wle"print -96.0.0.1" Argument "`\0\0^A" isn't numeric in negation (-) at -e line 1. 0 C:\DELL\v>perl -wle"print -97.0.0.1" -a ☺ C:\DELL\v>perl -wle"print -122.0.0.1" -z ☺ C:\DELL\v>perl -wle"print -123.0.0.1" Argument "{\0\0^A" isn't numeric in negation (-) at -e line 1. 0

Quite why that would be so I cannot fathom.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: version string oddities
by chrisdolan (Beadle) on Sep 24, 2006 at 05:03 UTC
    Interesting. So, it looks like it depends on whether Perl thinks the v-strings are valid barewords? A simple test:
    #!/usr/bin/perl -w for (0..255) { print "$_: "; eval "print -$_.0.0.1;"; print "\n"; }

    That reveals that [\w\-\+] all lead to no warnings. [A-Za-z_] (i.e. 65-90,95,97-122) are valid bareword starters. [0-9] (i.e. 48-57) lead to actual numbers. I don't understand "-" and "+" (i.e. 43 and 45).

    So it looks like Perl is aggressively changing v-strings into strings at compile time, and re-injecting those strings into the tokenizer. Weird....