Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | CGI | Q1505 [ previous next ]

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 );

©2018 Martin Webb