# untested; salt to taste my $html = $mech->content; $html =~ s/(]+>)(.*?]*>)/$2$1/; $mech->update_html($html);