in reply to Re: Mojo::DOM parsing question
in thread Mojo::DOM parsing question

I seem to be getting stuck trying to define my variable to print based on your help. I'm using:
my $abstr = $dom1->find('div.abstract-content > p')->each;
but gettting an error.

Replies are listed 'Best First'.
Re^3: Mojo::DOM parsing question
by hippo (Archbishop) on Jul 17, 2020 at 08:26 UTC

    each returns a list but you are calling it in scalar context. Use list context as marto did and you will be fine. See also: Context tutorial.

    but gettting an error.

    Don't keep it a secret. Always provide the full text of the error message.

Re^3: Mojo::DOM parsing question
by marto (Cardinal) on Jul 17, 2020 at 08:29 UTC

    Is there more than one abstract per html page? My example uses foreach to print the text for each match we find, using the selector which matches your requirement. See find. If you know for sure that each page has one abstract you could do something like my $abstract = $dom->at('div.abstract-content > p')->text;. If you post the error you have maybe I can provide more help, see also How do I post a question effectively?. In your example $abstr will contain the number of matches.