wfsp has asked for the wisdom of the Perl Monks concerning the following question:

The look_down method is not finding the DOCTYPE declaration although it is present in Data::Dumpers output as described in the docs. What's the best way to do this?
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; use HTML::TreeBuilder; my $content = do{local $/;<DATA>}; my $root = HTML::TreeBuilder->new_from_content($content); print $root->tag, qq{\n}; # prints: html print $root->{_decl}{_tag}, qq{\n}; # prints: ~declaration print $root->{_decl}{text}, qq{\n}; # prints: DOCTYPE html PUBLIC "XHTML" my $dec = $root->look_down( _tag => q{~declaration}, ) or die qq{declaration not found\n}; $dec->splice_content( 0, 1, q{<!DOCTYPE html PUBLIC "HTML4">}, ) or die qq{splice failed\n}; print $root->as_HTML; __DATA__ <!DOCTYPE html PUBLIC "XHTML"> <html> <head><title>declaration</title></head> <body><p>declaration</p></body> </html>
extract from Data::Dumper output
'_decl' => bless( { '_tag' => '~declaration', 'text' => 'DOCTYPE html PUBLIC "XHTML"' }, 'HTML::Element' ),