|
-
Feb 12th, 2013, 10:40 PM
#1
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?
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Feb 13th, 2013, 05:38 PM
#2
Re: How to translate HTML symbols to normal text in Perl
-
Feb 14th, 2013, 11:49 AM
#3
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
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Feb 14th, 2013, 06:15 PM
#4
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:
-
Feb 14th, 2013, 06:37 PM
#5
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
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Feb 15th, 2013, 01:59 AM
#6
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|