chrisdolan has asked for the wisdom of the Perl Monks concerning the following question:
What's the expected behavior with negation? I think negation should be meaningless because this is really a string not a number, right? Specifically, can someone explain these results (via Apple's Perl 5.8.6):%perl -le'print 127.0.0.1' | cat -v ^?^@^@^A
The first two are expected. The third one is baffling. The fourth appears to be treating the "65.0.0.1" as a string. In that sense, it resembles:% perl -le'print 64.0.0.1' | cat -v @^@^@^A % perl -le'print 65.0.0.1' | cat -v A^@^@^A % perl -le'print -64.0.0.1' | cat -v 0 % perl -le'print -65.0.0.1' | cat -v -A^@^@^A
In the "-64.0.0.1" case, the "64" is not special. Any number below 65 seems to trigger that result. Deparse doesn't really help explain anything either, except that Deparse is confused by the minus signs too:% perl -le'print -"aaa"' | cat -v -aaa
% perl -MO=Deparse -e'print 65.0.0.1' print 65.0.0.1; % perl -MO=Deparse -e'print 64.0.0.1' print 64.0.0.1; % perl -MO=Deparse -e'print -65.0.0.1' print "-A\000\000\cA"; % perl -MO=Deparse -e'print -64.0.0.1' print 0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: version string oddities
by ikegami (Patriarch) on Sep 24, 2006 at 04:34 UTC | |
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 | |
by chrisdolan (Beadle) on Sep 24, 2006 at 04:47 UTC | |
|
Re: version string oddities
by BrowserUk (Patriarch) on Sep 24, 2006 at 04:38 UTC | |
by chrisdolan (Beadle) on Sep 24, 2006 at 05:03 UTC |