OK, I'm playing with WWW::Mechanize at the moment and it's thrown up what is for me an interesting question, and a good chance to learn about references

TO quote WWW::Mechanize one of the pieces of information that can be retrieved is a reference to an array containing an array reference for every <A> and <FRAME> tag and that for each <A> tag, element[0] contains the text of the href and element[1] contains the text enclosed by the <A> tag

Through reading some of the tutorials and various chunks of perl books, I've come up with the following code which will let me view all of (say) the element[0]'s:

foreach (@{$w->{links}}) { print $$_[0]."\n"; }

Now what I'd really like is to generate an array containing all of the element[0]'s which I can obviously do using the above loop and pushing onto an array - but is there some easy way through referencing that would let me do it without the loop?


In reply to References and arrays by sch

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.