Perl has a feature where barewords preceeded by a minus need not be quoted. This allows people to do function -optiona -optionb;.

>perl -wle "print abc;" Unquoted string "abc" may clash with future reserved word at -e line 1 +. Name "main::abc" used only once: possible typo at -e line 1. print() on unopened filehandle abc at -e line 1. >perl -wle "print -abc;" -abc

When your v-string gets packed into something which starts with a letter, you see this autoquoting in effect.

>perl -wle "print -90.0.0.1" -Z^@^@^A >perl -wle "print -91.0.0.1" Argument "[\0\0^A" isn't numeric in negation (-) at -e line 1. 0

Apparently, it didn't occured to the implementors of these features to test them used together. What you are expecting from the negation of a string?

Update: If you want to work with 90.0.0.1 as a number, unpack it.

$uint32_ip = unpack 'N', 90.0.0.1;

Once unpacked, you'll be able to manipulate it using numerical operators (including -, <<, >>, ^, | and &).

Update: Better yet, use one of the existing modules (such as Net::IP or NetAddr::IP).


In reply to Re: version string oddities by ikegami
in thread version string oddities by chrisdolan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.