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 ;-)
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |