I echo this confusion ... in particular, what confuses me the most is: what is the point of the +0 ?

In what situation do you (intentionally) want/get a different result from int($str+0) vs int($str) ???

As an aside, your regular expressions would be better written as ...

I don't believe the OP is saying they intend to replace the int(...) with a regex, I believe they are assuming int(...) is implemented via a regex?

The key reason why int("information") returns Inf is because of the intended usage of the function, per the docs...

int EXPR int Returns the integer portion of EXPR. If EXPR is omitted, u +ses $_. ...

...the key word being "portion". The If you give it a scalar, it's going to consume as much of that scalar as it can to produce an integer:

$ perl -le 'print int("32hike")' 32

In reply to Re^2: Weird behavior of int() by hossman
in thread Weird behavior of int() by cLive ;-)

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.