You don't do the "local $/;" bit. That was just to provide a stand alone chunk of demo code using a temporary file. A sample closer to your actual issue looks like:
use strict; use warnings; use HTML::Parser; open OUT, '>', 'delme1.txt'; print OUT <<STR; <html><head></head> <body> <p>The use of the Porter and Ale is more prevalent in England. In the United States ½ Old and ½ New Ale is usually used when this drink is called for, unless otherwise specified.</p> </body> </html> STR close OUT; my $p = HTML::Parser->new( api_version => 3, text_h => [\&text, "dtext"], ); $p->parse_file ('delme1.txt'); sub text { my($origtext) = @_; $origtext =~ s/½/\½/g; print $origtext; }
Prints:
The use of the Porter and Ale is more prevalent in England. In the United States ½ Old and ½ New Ale is usually used when t +his drink is called for, unless otherwise specified.
but still doesn't show the problem you are experiencing. Perhaps you can modify the sample until it does show the error?
In reply to Re^3: How do I regex for characters like ¾, ¼ ?
by GrandFather
in thread How do I regex for characters like ¾, ¼ ?
by Plankton
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |