|
|
| Come for the quick hacks, stay for the epiphanies. | |
| PerlMonks |
Re: Access a global variable from a subroutine when used as "for" iteratorby johngg (Canon) |
| on Dec 20, 2023 at 21:26 UTC ( [id://11156430]=note: print w/replies, xml ) | Need Help?? |
|
You could use a subroutine reference and form a closure over $i using a do block so that it remains in scope outside the block.
I hope this is helpful. Cheers, JohnGG
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||