Tell someone on the StackOverflow user page that you want to replace all PERL instances with Perl. You can do it with
#! /usr/bin/perl use warnings; use strict; use HTML::Parser; use LWP::Simple; my $html = get "http://stackoverflow.com/users/201469/phil-jackson"; die "$0: get failed" unless defined $html; sub replace_text { my($skipped,$markup) = @_; $skipped =~ s/\bPERL\b/Perl/g; print $skipped, $markup; } my $p = HTML::Parser->new( api_version => 3, marked_sections => 1, case_sensitive => 1, unbroken_text => 1, xml_mode => 1, start_h => [ \&replace_text => "skipped_text, text" ], end_h => [ \&replace_text => "skipped_text, text" ], );
The result is what we expect:
$ wget -O phil-jackson.html http://stackoverflow.com/users/201469
$ ./replace-text> out.html
$ diff -ub phil-jackson.html out.html
--- phil-jackson.html
+++ out.html
@@ -327.7 +327.7 @@
Perl:
- # $ linkTrue = & hellip; "> comparing PERL md5 () and PHP md5 () </a> </h3>
+ # $ linkTrue = & hellip; "> comparing Perl md5 () and PHP md5 () </a> </h3>
<div class = "tags t-php t-perl t-md5">
<a href="/questions/tagged/php" class="post-tag" title="show questions tagged'php'" rel="tag"> php </a> <a href = "/ questions / tagged / perl "class =" post-tag "title =" show questions tagged 'perl' "rel =" tag "> perl </a> <a href =" / questions / tagged / md5 "class =" post-tag "title = "show questions tagged 'md5'" rel = "tag"> md5 </a> "PERL:" the sore finger is part of the attribute of the element, not the text section.
source share