in reply to Pattern Matching and replacement
The $attr->{value} = "foo" if $attr->{name} eq "bar" part can be as complex as desired, obviously.use strict; use warnings; use HTML::TokeParser::Simple; my $p = HTML::TokeParser::Simple->new("foo.html"); sub new_form_tag { my ($attr) = @_; $attr->{value} = "foo" if $attr->{name} eq "bar"; return join " ", "<input", map(qq($_="$attr->{$_}"), keys %$attr), + ">"; } while(my $token = $p->get_token) { print $token->is_start_tag('input') ? new_input_tag($token->return_attr) : $token->as_is; }
Makeshifts last the longest.
|
|---|