sch has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: References and arrays
by zigdon (Deacon) on Oct 08, 2002 at 17:57 UTC | |
by sch (Pilgrim) on Oct 09, 2002 at 08:16 UTC | |
by sch (Pilgrim) on Oct 08, 2002 at 18:14 UTC | |
|
Re: References and arrays
by sauoq (Abbot) on Oct 08, 2002 at 18:02 UTC |