I have created a CGI-based page,after entering all the
values in to the fields, How to get the output on the web
browser using Perl

Answer Posted / vipul dalwala

print "content-type: text/html\n\n";.

if ($ENV{’REQUEST_METHOD’} eq ’POST’) {
read(STDIN, $buffer, $ENV{’CONTENT_LENGTH’});
}
else {
$buffer = $ENV{’QUERY_STRING’};
}

@keyvaluepairs = split(/&/, $buffer);

foreach $pair (@keyvaluepairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex
($1))/eg;
print $name . "=". $value ."<br>";
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does a “grep” function perform?

806


Perl uses single or double quotes to surround a zero or more characters. Are the single(' ') or double quotes (" ") identical?

738


What does read () command do?

709


Explain which feature of PERL provides code reusability?

949


explain the various functions/directives in perl that allow you to include/import a module. Also, state the differences between them.

665


How to read multi lines from a file in perl?

715


Explain about typeglobs?

735


Explain string comparison operators in perl.

794


How to read file into hash array ?

813


what is Chop & Chomp function does?

797


Write syntax to add two arrays together in perl?

728


How the interpreter is used in Perl?

738


What syntax is used for grep() function?

824


Why should I use the -w argument with my Perl programs?

772


Explain split function in perl?

772