CGI Programming / Scripts Question:
Download Job Interview Questions and Answers 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 );
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 Question | Next Question |
When do I need to use CGI? | What is the difference between object oriented and structured oriented programming? |