The docs discuss inline editing under the $h->contents_refs_list
You may have to adjust depending on how "unpredictable" the HTML is.
output#!/usr/local/bin/perl use strict; use warnings; use HTML::TreeBuilder; my $root = HTML::TreeBuilder->new_from_file(*DATA) or die qq{cant build tree\n}; my $noclass = $root->look_down( _tag => q{div}, class => q{noclass}, ); die qq{noclass not found\n} unless $noclass; my $replaced; for my $item_r ($noclass->content_refs_list) { next if ref ${$item_r}; ${$item_r} = lookup_replacement(${$item_r}); $replaced++; } die qq{no replace\n} unless $replaced; my $html = $root->as_HTML(undef, qq{ }, {}); print qq{$html\n}; sub lookup_replacement{ my $lookup = shift; # find replacement return q{something}; } __DATA__ <html> <head> <title>tb_test</title> </head> <body> <div align="center" class="noclass">nothing</div> </body> </html>
<html> <head> <title>tb_test</title> </head> <body> <div align="center" class="noclass">something</div> </body> </html>
In reply to Re: Editing HTML files
by wfsp
in thread Editing HTML files
by spivey49
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |