http://qs321.pair.com?node_id=11147005


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've tried adding the no warnings 'recursion'; to both the example script above and to the real script (there in the smallest lexical scope available). It does not suppress the warnings in either case.

I wonder if there would be a way to simply collect and not print the warnings, perhaps with an eval. However, the attempt below still prints the same warnings as the original example script above.

#!/usr/bin/perl use HTML::TreeBuilder::XPath -weak; use strict; use warnings; my $ent = HTML::TreeBuilder::XPath->new; $ent->parse_file(\*DATA); eval { no warnings 'recursion'; $ent->delete; }; if ($@) { print "FOO\n"; } exit(0); __DATA__ <html> <head> <title>foo bar</title> </head> <body> foo <br /> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <center> <strong>bar</strong> <br /> <center>(baz)</center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </center> </body> </html>