while(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"; } } } }