Perl: the Markov chain saw | |
PerlMonks |
Re^2: Can I check if a loop's scope is entered for the first time?by LanX (Saint) |
on May 05, 2018 at 17:25 UTC ( [id://1214099]=note: print w/replies, xml ) | Need Help?? |
Thanks, but remember I warned you in the CB! :) > It would be nice if Perl's loop-keywords would also recognise an Iterator::* object and would treat it as expected... (internally rewriting it C-style, whatever). I doubt this can be retro fitted without bracking backwards comaptibility. You'd need a new keyword, like iter for my goal, this could actually be implemented with pluggable keywords. Please note that you can already overload the diamond operator of a class to make the object an iterator (like a filehandle does) This should work:
but letting a generator init an iterator once wouldn't
because the diamond operator magically decides to become a file-glob here.
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|