How to translate HTML symbols to normal text in Perl
I have a script program that I tried using the following code:
Code:
'
'
$value =~ tr/+/ /;
$value =~ tr/%21/!/;
$value =~ tr/%22/"/;
$value =~ tr/%25/%/;
$value =~ tr/%26/&/;
$value =~ tr/%28/(/;
$value =~ tr/%29/)/;
$value =~ tr/%2C/,/;
$value =~ tr/%2F/|/;
$value =~ tr/%3C/>/;
$value =~ tr/%3D/=/;
$value =~ tr/%3E/</;
'
'
Unfortunately it does'nt do what I though it would do.
I want to take each HTML code like %xx and change it to the real character.
For example %3E = "<" and %3C = ">"
Anyone know how to do this?
Re: How to translate HTML symbols to normal text in Perl
Re: How to translate HTML symbols to normal text in Perl
The example from that link don't work
my $original = "Colon : Hash # Percent %";
my $escaped = uri_escape( $original );
print "$escaped\n"; # 'Colon%20%3A%20Hash%20%23%20Percent%20%25'
Once it hits the 2nd line nothing else beyond that point is executed
Re: How to translate HTML symbols to normal text in Perl
Do you have URI::Escape installed?
Run the following from a terminal/console window:
Code:
perl -MURI::Escape -e ""
If it reports URI::Escape not found, then you need to install it with:
Re: How to translate HTML symbols to normal text in Perl
I was wondering about that myself. I don't really have access to the Perl interpreter as it is owned by the hosting company of my web site where I keep the Perl CGI programs I write. Maybe I need to contact C.S. at the company and address this with them.
Thanks for your help
Re: How to translate HTML symbols to normal text in Perl
Yes. I would contact your hosting company to see if they have that module available. They might even install it for you, if you get lucky. I would think it must be a popular module since it's referenced from the PerlFAQ.
Failing that, you could include the module yourself by putting the module file(s) into a separate directory (outside of the www root) and then including it with a combination of lib and FindBin.