Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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 []

    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 - or it is specific to Mojo:OM ?
    IMHO on Mojo:OM homepage I did not found any mention about "each" under methods section Mojo DOM -
    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')
    Same issue as above for "map" and "sub" methods
    map - sub -

    - 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

  2. #2
    Linux Newbie nplusplus's Avatar
    Join Date
    Apr 2010
    Charlotte, NC, USA
    Hi, Makatana,

    I cannot answer your final two questions, but about the "each" method in general, have a look here, Mojo:OM -, which leads to here, Mojo::Collection - Basically, each is a method of a Mojo::Collection object as returned by the "find" method of Mojo:OM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts