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.