in reply to Stringing method calls

Can't you just put an  eval block around the statement? Should avoid dying and leave you with an undef'd  $text if one of the subnodes doesn't exist:

my $text; eval{$elt->first_child( 'sub_elt')->first_child( 'subsubelt')->text;}

Or did I miss something?

pike

Replies are listed 'Best First'.
Re: Re: Stringing method calls
by mirod (Canon) on Oct 11, 2001 at 15:44 UTC

    I certainly could. The problem is that I am not the only one (I hope!) using the module, and I want to make it as easy as possible for people who are not familiar with eval to use the module.

    Maybe after all I should just add this to the documentation, along with something restating the eval { BLOCK } is _not_ slow (it seems that a lot of people avoid eval systematically on account of it being slow, when only the eval "string" version can be slower if included in a loop for example).