EvoTalk

24 六月, 2009

Javascript Like escape and unescape Functions in PERL

Posted by: asd In: Code Snippet| Perl| 程式設計 ()

PERL:
  1. sub escape {
  2. my($str) = splice(@_);
  3. $str =~ s/(\W)/sprintf('%%%02X', ord($1))/eg;
  4. return $str;
  5. }
  6.  
  7. sub unescape {
  8. my($str) = splice(@_);
  9. $str =~ s/%(..)/chr(hex($1))/eg;
  10. return $str;
  11. }

Releated Posts



No Responses to "Javascript Like escape and unescape Functions in PERL"

Comment Form


  • BK: 大於和小於在今日更廣泛地使用於標籤上,故在此補充該英文用法: : angle bracket []: square bracket
  • luh1688: 非常實用且謝謝!~
  • asd: 好的,不過很久沒修改了,不知道能不能動 寄到您的yahoo信箱
  • LIANG: nice post, thank you
  • Justmaker: 您好,請問可以跟你要source嗎?我最近有在看股票,想要enhance您的小工具,不知是否可以開放?

Category