CGI Programming / Scripts Question:
Download Questions PDF

Is there an equivalent of JavaScripts escape() function in Perl?

Answer:

Try This:

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

# ...or...

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

Download CGI Programming Interview Questions And Answers PDF

Previous QuestionNext Question
When do I need to use CGI?What is the difference between object oriented and structured oriented programming?