CGI Programming / Scripts Question:

Download Job Interview Questions and Answers PDF

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

CGI Programming Interview Question
CGI Programming Interview Question

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?