Perl - 如何解码或替换'从数据库到单引号浏览器显示

时间:2011-01-22 19:56:43

标签: mysql perl decode

我发现很多问题接近于此,但没有任何帮助我解决它的问题。由于我缺乏专业知识,这是个问题。

PHP有html_entity_decode这可能有所帮助,但Perl没有,我相信。

在我的MySQL数据库中,我在' "

这样的描述中有12' 6"个跟随长度

我希望它显示为12'6“。

我试过了:

$string =~ s/:[']:/'/g;
$string =~ s/:["]:/"/g;
$string =~ s/'/'/g;
$string =~ s/"/"/g;
$string =~ s/\'/'/g;
$string =~ s/\"/"/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.

我不知所措。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:6)

查看HTML::Entities

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

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