News for hackers. Stuff that matters.
Re:Perl is 25 years old today by hercynium on Tuesday December 18, 2012 @05:31PM (#4939994)
For list comprehensions and a different style of generator, look at https://metacpan.org/module/List::Gen

And then there are a pile of modules that implement python-style generators, some using https://metacpan.org/module/Coro (co-routines implemented as threads), some using crazy hacks:

https://metacpan.org/module/Compile::Generators

https://metacpan.org/module/Coro::Generator

https://metacpan.org/module/Attribute::Generator

Re:Perl is 25 years old today by ajross on Tuesday December 18, 2012 @08:56PM (#4940787)
Yeah, honestly though those fail the "clean" test for me. What I really meant isn't the computational capabilities of python generators but the way the mesh nicely with the way builtins like "in" or "all()" or "any()" work on plain old data. Reasoning about them, in general, isn't any harder than reasoning about a dict or list in the common case, and that's a feature missing from the perl equivalents which try to do it in a library. I'd feel comfortable throwing a comprehension into code intended to be maintained by a novice. I'd never inflict any of that junk on the poor maintainer.