#!/usr/bin/perl use warnings; use strict; our $html = <<'EOHTML';
The relationship can be expressed by the following equation:
y <= (7x3 + 3x2)/((x - 3)(x - 5)
Of course x != 3 & x != 5 -- That goes without saying.
:)
EOHTML
use HTML::Parser;
my $parser = HTML::Parser->new(
handlers => {
default => [sub { print @_ }, 'text'], # print out HTML tags unmodified
text => [\&process_text, 'text'],
},
);
$parser->parse($html);
sub process_text {
$_ = shift;
# Make any changes to the text here...
s/--/—/g;
s/:\)/ The relationship can be expressed by the following equation: Of course x != 3 & x != 5 — That goes without saying.
/g;
# and so forth.
# Now print out the modified text.
print;
}
####
y <= (7x3 + 3x2)/((x - 3)(x - 5)