1

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/\"/"/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?

1 Answers1

6

Have a look at HTML::Entities:

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

my $str = '12' 6"';
print decode_entities($str);
cjm
  • 61,471
  • 9
  • 126
  • 175
ccheneson
  • 49,072
  • 8
  • 63
  • 68