Update: Now I look back, I see JavaFan made this exact point, so just see that reply.
2. Move right character by character, and throw away stuff that doesn't look like a number. If you never see a number, return 0.
3. When you find the first number, collect characters ...
I would quarrel with those assertions. Perl only looks for a number in the left-most part of the string. With warnings:
>perl -wMstrict -le
"print 1 + 'x2x3x';
print 1 + '2x3';
"
Argument "x2x3x" isn't numeric in addition (+) at -e line 1.
1
Argument "2x3" isn't numeric in addition (+) at -e line 1.
3