I also did run the tests under some configurations, and was able to reproduce some results :

Linux x86 box : corion@samson > perl -v This is perl, version 5.005_02 built for i586-linux blah blah corion@samson >perl -w test.pl Argument "0x1" isn't numeric in add at test.pl line 4. 01: 1 Argument "0x2" isn't numeric in add at test.pl line 4. 02: 1 Argument "0x3" isn't numeric in add at test.pl line 4. 03: 1.5 Argument "0x4" isn't numeric in add at test.pl line 4. 04: 1 ... etc ... corion@samson:~ > perl -e "print "0x30"+0;" 48corion@samson:~ >
I'm not sure what the issue with the test from the command line is, because here I use wrong double quotes which could be messed with by the shell (bash). I can confirm the other results with ActivePerl 5.005 build 517 (yes, I'm running that ancient version here), and the weird quotes trick also works under cmd.exe and NT :
F:\>perl -e "print "0x30"+0;" 48
Whatever this means, but maybe some perl luminary can enlighten us.

Update :Under Win32, ActivePerl build 517, the script works as expected, printing 0 for each number.


In reply to Re: Why are hex numbers inside strings extrapolating to numbers (incorrectly)? by Corion
in thread Why are hex numbers inside strings extrapolating to numbers (incorrectly)? by Anonymous Monk

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.