package Undef;
sub AUTOLOAD {
undef;
}
####
$text = ((
$elt->first_child( 'subelt') || 'Undef'
)->first_child( 'subsubelt')||'Undef'
)->text();
####
# Takes an array of anon arrays of method calls, and
# chains them. Returns the first non-object of the end of
# the call.
sub chain_meth {
my $obj = shift;
my $last_call = pop;
foreach my $call (@_) {
my ($meth, @args) = @$call;
$obj = $obj->$meth(@args);
return $obj unless ref($obj);
}
# Make the last one respect context properly.
my ($meth, @args) = @$last_call;
return $obj->$meth(@args);
}
####
$text = $elt->chain_meth(
["first_child", "subelt"], ["first_child", "subsubelt"], ["text"]
);