开发者

Perl - How to decode or replace ' from database to single quote for browser display

I have found lots of questions close to this but, nothing that helped me solve it. Prob due to my lack of expertise.

PHP has html_entity_decode which could have helped but, Perl does not, I believe.

In my MySQL database I have ' " following lengths in a description like: 12' 6"

I would like it to display as 12' 6".

I have tried:

$string =~ s/:[']:/'/g;
$string =~ s/:["]:/"/g;
$string =~ s/'/'/g;
$string =~ s/"/"/g;
$string =~ s/\'/'/g;
$string =~ s/开发者_如何学JAVA\"/"/g;
$string =~ s/\'/\'/g;
$string =~ s/\"/\"/g;
perl -pi -e 's:':':g' $_; #crashes.
perl -pi -e 's:":":g' $string #also crashes.
system -pi -e 's:':':g' $_; #crashes.
system -pi -e 's:":":g' $string #also crashes.

I am at a loss. Can someone help?


Have a look at HTML::Entities:

use warnings;
use strict;
use HTML::Entities;

my $str = '12' 6"';
print decode_entities($str);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜