A quick look at the HTML::Element documentation suggests using the content_list method, as in my $date = ($d->content_list)[1]. If there was no element 1 in the content list (as when the element is empty), this will set $date to undef and might produce a warning.
Alternately, your use of content was very close: the content method returns an arrayref or undef, so you want my $date = $d->content->[1] but note that that will crash if the element has no content, so you might want to use eval: my $date = eval { $d->content->[1] } which will set $date to undef (and set $@ to an error about attempting to dereference something that was not a reference) if the element has no content.
(All code obviously untested.)
In reply to Re: HTML::Element accessing "internal attributes" the proper way
by jcb
in thread HTML::Element accessing "internal attributes" the proper way
by cormanaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |