Killing passed text...

This should be simple: is there a way to supress the output of the special escape characters in Perl?  In other words, if the user enters something like:

"I like to eat cheese!"

Can I keep it from being passed as:

"I+like+to+eat+cheese%21"?  

I need to output the text back to HTML, and it's obviously no good to me like this.  Do I just have to do an s///?  Or is there an easier way?
LVL 3
RaydotAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
maneshrConnect With a Mentor Commented:
if you have the URI::Escape PERL module, try this....

if you dont, i would suggest that you install the same from www.cpan.org.

its very useful, since you dont have to worry about all the special characters to escape and unescape.

==============escape.pl
#!/usr/local/bin/perl

use URI::Escape;

$str="I like to eat cheese!";

print "Original string ",$str,"\n";
$safe = uri_escape($str);
print "After Escaping ",$safe,"\n";

$str  = uri_unescape($safe);
print "After Un-Escaping ",$str,"\n";
0
 
binkzzCommented:
You can't pass it any other way, but you can decode it by using two regular expressions:

$key=~s/\+/ /g;
$key=~s/%([0-9a-fA-f]{2})/pack("c",hex($1))/ge;

Binkzz
0
 
ozoCommented:
why not pack("H*",$1)?
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
binkzzCommented:
It works and doesn't particulary slow down the system
0
 
binkzzCommented:
Can I just find out what's actually wrong with my solution?

Binkzz
0
 
RaydotAuthor Commented:
Who said there was anything wrong with your solution?  I think man and ozo are just offering alternatives.

I'll have to check for that URI::Escape module...Ozo, I don't really understand your pack solution.  Thanks!
0
 
RaydotAuthor Commented:
Did y'all think I forgot about this question?  Thanks for all your help!
0
All Courses

From novice to tech pro — start learning today.