in reply to Trouble Traversing Hash and Array References
You can not dereference a string "HASH(0x1a031f4)" because it is not a reference. Your $array is a reference to an object HTML::Element, so use it's methods
see HTML::Elementwhile(my ($key, $value) = each(%{$tree})) { if (ref($value) eq 'ARRAY') { foreach my $array (@{$value}) { for (@{ $array->extract_links('a', 'img') }) { my($link, $element, $attr, $tag) = @$_; print "Hey, there's a $tag that links to ", $link, ", in its $attr attribute, at ", $element->address(), ".\n"; } } } }
Update: misprints fixed
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Trouble Traversing Hash and Array References
by bkiahg (Pilgrim) on Aug 23, 2004 at 15:04 UTC |