in reply to version string oddities
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).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: version string oddities (-bug)
by tye (Sage) on Sep 24, 2006 at 04:57 UTC | |
by chrisdolan (Beadle) on Sep 24, 2006 at 05:06 UTC | |
by gustavderdrache (Acolyte) on Sep 24, 2006 at 20:00 UTC | |
|
Re^2: version string oddities
by chrisdolan (Beadle) on Sep 24, 2006 at 04:47 UTC |