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
In reply to Re^2: 'Dynamic scoping' of capture variables ($1, $2, etc.)
by nvivek
in thread 'Dynamic scoping' of capture variables ($1, $2, etc.)
by AnomalousMonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |