Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1505 Is there an equivalent of JavaScript's escape() function in Perl?

irt.org | Knowledge Base | CGI | Q1505 [ previous next ]

Q1505 Is there an equivalent of JavaScript's escape() function in Perl?

Try:

require CGI;
$escaped = CGI::escape( $normal );

#   ...or...

sub escape {
  my $str = shift || '';
  $str =~ s/([^\w.-])/sprintf("%%%02X",ord($1))/eg;
  $str;
}
$escaped = escape( $normal );

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.