in reply to Open, Find, Replace, Rewrite, Close.. Advice on best path to take

Parsing HTML with regexps is error prone. HTML::Parser, HTML::TreeBuilder, etc are great tools. Here is a short example:
my $str = q{ <span id=editArea name="whatever"> bla bla a bunch of html and text that will change from file to file </span> }; use HTML::TreeBuilder; my $t = HTML::TreeBuilder->new_from_content($str); foreach ($t->look_down('_tag', 'span')) { next if $_->attr('id') ne 'editArea' || $_->attr('name') ne 'whate +ver'; $_->delete_content; $_->push_content('this is some replacement text'); } print $t->as_HTML; $t->delete;

gav^

  • Comment on Re: Open, Find, Replace, Rewrite, Close.. Advice on best path to take
  • Download Code