Starting with version 1.23, the specified language has added support for iterators, which lets us range over pretty much anything!
Let’s look at the List type again. In that example, we had an AllElements method that rendered a list of all elements. With iterators, we can do it better - as shown below.
To run this Perl script, save the code to a file and execute it using Perl.
Outputs:
Now that we can run and use basic iterators in Perl, let’s learn more about the language.