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 to open a directory in perl?

530


What is the difference between use and require in perl programming?

511


What is perl programming?

551


Write syntax to use grep function?

550


Explain '->' in perl?

500






What is perl shift array function?

520


What is the difference between perl array and perl hash?

519


Remove the duplicate data from @array=(“perl”,”php”,”perl”,”asp”)

614


How would you ensure the re-use and maximum readability of your perl code?

518


Explain the difference between die and exit in perl?

437


Why do you use Perl?

541


What is cpan ? What are the modules coming under this?

500


How many types of primary data structures in Perl and what do they mean?

845


Differences between die and exit.

612


What is a chomp() function in perl?

511