Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

How to print a Mojo::Collection Array

by Anonymous Monk
on Dec 13, 2022 at 17:19 UTC ( [id://11148833]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I'm using Mojo to parse html and am trying to print the array that I have grabbed and I am getting the following when I print $r2: r2 = Mojo:Collection=ARRAY (0x7fa51ac83968). How can I print the content of the array? This is the code I used to grab the html that I wanted.

$r2 = $dom2->find('[class="fuLhoc ZWArf"]' ) ->map (sub{$_->all_text});

Thanks in advance for any assistance that you can provide

Replies are listed 'Best First'.
Re: How to print a Mojo::Collection Array
by Fletch (Bishop) on Dec 13, 2022 at 18:13 UTC

    If you call the to_array method on one it'll return a vanilla array ref which you can pass to your favourite debugging helper (e.g. Data::Dumper, or YAML::XS; or use encode_json from Mojo::JSON).

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11148833]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-25 16:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found