Perl-Sensitive Sunglasses PerlMonks

### Comment on

 Need Help??
For clear definition, as \$_ value got changed in every recursive call of R() function, \$1 value also got changed and in return of every recursive call, the last changed value available and that is the reason for getting '1' 5 times in \$1. For better understanding, here below I have shown how that recursive calls and values of \$_ and \$1 will be.

Initial ( First ) callback of R() function:
\$_='x55x666x7777x1x'; \$_=undefined;
Inside code, after evaluating s/(\d+)// ? \$1 + R() : 0;
\$1=55; #immediately after executing s// command
Second callback of R():
\$_='xx666x7777x1x'; \$1=55;
Inside code, after evaluating s/(\d+)// ? \$1 + R() : 0;
\$1=666; #immediately after executing s// command
Third callback of R():
\$_='xxx7777x1x'; \$1=666;
Inside code, after evaluating s/(\d+)// ? \$1 + R() : 0;
\$1=7777; #immediately after executing s// command
Fourth callback of R():
\$_='xxxx1x'; \$1=7777;
Inside code, after evaluating s/(\d+)// ? \$1 + R() : 0;
\$1=1; #immediately after executing s// command
Fifth callback of R():
\$_='xxxxx'; \$1=1;
Inside code, after evaluating s/(\d+)// ? \$1 + R() : 0;
# no callback executed as ( there are no digits ) pattern not matched
\$1=undefined; #immediately after executing s// command
# after prints 'xxxxx' and '1' for fifth callback
# after prints 'xxxxx' and '1' for fourth callback
# after prints 'xxxxx' and '1' for third callback
# after prints 'xxxxx' and '1' for second callback
# after prints 'xxxxx' and '1' for first callback

Kindly regret me for format. I unable to get exact stack of recursive calls for presentation.
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, 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, 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: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?
• See Writeup Formatting Tips and other pages linked from there for more info.
• Log In?
 Username: Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2018-06-17 22:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Should cpanminus be part of the standard Perl release?

Results (107 votes). Check out past polls.

Notices?