in reply to
Perl bug or what?
There is no known issue with the transformation you have described above.
Please read Basic debugging checklist. In order to be helpful here, the monks will need more context. Please take the two scripts which are displaying different behavior, and make them as simple as possible while still displaying the issue you mention. For example, I get successful conversion with the one-liner
perl -E '$string = "5abc"; $x = 0 + $string; print "$x\n"'
Also, please wrap you code in <code>
tags to avoid formatting headaches; see How do I post a question effectively?
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.