Perl syntax and html ole parsing

Hi gurus
I am trying to understand some advanced (for me) perl constructions (syntax) following this tutorial I am trying to parse html:
Using Mojo::DOM | Joel Berger [blogs.perl.org]

say "div days:";
say $_->text for $dom->find('div.days')->each;

say "\nspan hours:";
say $_->text for $dom->find('span.hours')->each;

What does this syntax mean, what is going on here ?

  • What kind of loop is this, classic for construction looks like this: for(i=0;i<10;i++){ code } not: {code} for (some_condition)
  • What does "each" keyword mean in this context ? Does it have somethin common with "each" build in perl function
    each - perldoc.perl.org or it is specific to Mojo::DOM ?
    IMHO on Mojo::DOM homepage I did not found any mention about "each" under methods section Mojo::DOM - search.cpan.org
    so it must be a build in function of perl, but this buildin "each" function has completelly different syntax, how is this possible, am I missing somethin ?

Another example from tutorial page

say "Open Times:";
say for $dom->find('div.openTime')
            ->map(sub{$_->children->each})
            ->map(sub{$_->text})
            ->each;

Same issue as above for "map" and "sub" methods
map - perldoc.perl.org sub - perldoc.perl.org

  • Can be those pieces of "Perlish" code rewriten in more "C specific" maner so I can understand it?
  • Most important: How to list all methods their parameters and return values contained in Mojo::DOM ?
    it must be done somehow, because I read that even for perl there are IDE with intelisense (autcompletition) so this IDE must know the methods return value types etc.

Thank you very much

Not a PERL guy yet, but I suppose that if a method returns a collection of one then each will pull that item from the collection, even though each is usually used with many item collections. Searching a collection with a regex might return more that one item, so returning a collection generalizes the search, returning a subset in a container.