There are fundamental things in Perl, which might be confusing here

  1. a scalar variable can be a number or a string (or a reference ...)
  2. There are various literal notations in code
  3. literals like "txt" , 'txt' , q(txt) , ... will produce the same string txt
  4. literals like 016 , 0xE , 14 will produce the same number (well integer) 14
  5. a string might look like a literal notation of a number like "016" , but literal notation inside strings will not be interpreted
  6. an implicit string to number conversion will always be decimal, hence "016" + 3  == 19 not 17
  7. if you want another base, you need to convert the string explicitly by yourself
  8. one (dangerous) way is eval("016") == 14

I hope it's clearer now.

Cheers Rolf
(addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
Wikisyntax for the Monastery


In reply to Re^3: octal number mysteriously changes after pass to subroutine by LanX
in thread octal number mysteriously changes after pass to subroutine 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.