Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Unnesting deeply nested HTML elements (Deep recursion on subroutine "HTML::Element::delete")

by mldvx4 (Friar)
on Sep 20, 2022 at 02:16 UTC ( [id://11147003] : note . print w/replies, xml ) Need Help??


in reply to Re: Unnesting deeply nested HTML elements (Deep recursion on subroutine "HTML::Element::delete")
in thread Unnesting deeply nested HTML elements (Deep recursion on subroutine "HTML::Element::delete")

Thanks. I see the same warnings whether I have "use HTML::TreeBuilder::XPath -weak; or plain old "use HTML::TreeBuilder::XPath; there at the beginning. What would have been the expected difference? Or, in other words, how would I know for sure whether I can omit the deletion?

Replies are listed 'Best First'.
Re^3: Unnesting deeply nested HTML elements (Deep recursion on subroutine "HTML::Element::delete")
by bliako (Monsignor) on Sep 20, 2022 at 08:21 UTC

    I think anon is telling you that you do not need to use delete at all with "modern" HTML::Element. See delete. OTOH even if you don't explicitly use delete perhaps HTML::Element will (edit: see Edit2 below), when you undef an element. And thus you will still get the warnings.

    Generally, having "deep recursion" warnings is not harmful at all because you may well have a structure which is more than 100 deep. And that's fine (until your memory is exhausted). However, the real problem is whether WordPress managed to produced some HTML which parsing it causes cyclical paths somehow. Then you may get infinite recursion and that's real bad. I would investigate that before supressing the warnings.

    bw, bliako

    Edit: by delete I mean HTML::Element::delete()

    Edit2: with weak references ON, as anon mentioned, it's the Perl interpreter/garbage collector who does the cleaning up as soon as the parent object goes out of scope or set to undef. I am trying to not give the impression that delete will be called internally with the "modern" regime.