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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |