sub {push @myArray, $_; } It fails! I am trying to understand how I can capture the output in your sub into an array.

pushing the results onto an array works fine for me, so you'd have to show an SSCCE of how it's failing for you. However, note that you don't need to create a new array - the return value of the ->find method is a Mojo::Collection object, which is basically just a fancy array reference. In other words, you can do my $c = $dom->find(...) and then @$c is the array of results - an array of Mojo::DOM objects. Just a guess, but perhaps you need to look at those docs to see what you can do with such objects, such as for example calling their ->all_text method to get their contents. (You can use Perl's grep, map, and other array operations on @$c, or you can use Mojo::Collection's methods such as $c->grep(...) and $c->map(...), which have a different API and return Mojo::Collection objects. ->each is basically the object's version of Perl's foreach.)


In reply to Re^3: Regular Expression Help by haukex
in thread Regular Expression Help by vskatusa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.