siddheshsawant has asked for the wisdom of the Perl Monks concerning the following question:

I was following the tutorial http://www.cgi101.com/book/ch4/text.html and copied the exact code of post.cgi. I place bot html & corresponding CGI code in /var/www/html directory and then visited the page through URL.When I used to press Submitt button the control transferred to the cgi page where I used to get the content of the CGI script as it like this :

------------------------------------------------------------
#!/usr/bin/perl -wT use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use strict; print header; print start_html("Thank You"); print h2("Thank You"); my %form; foreach my $p (param()) { $form{$p} = param($p); print "$p = $form{$p}<br>\n"; } print end_html;
-----------------------------------------------------------

But the desired output is

Thank You Siddhesh

name = siddhesh

email = sid123@gmail.com

comments = hello !!!!

--------------------------------------------------------

Why is it so???

Replies are listed 'Best First'.
Re: Question on CGI-PERL
by Corion (Patriarch) on Mar 03, 2010 at 20:06 UTC

    It seems you haven't configured your web server to execute the program, so it sends your program as a file. Read your webserver documentation on how to configure it to run CGI programs.

      But can I keep my CGIU code in html folder itself???

        Of course you can. You just have to configure your webserver to allow it (assuming you have access/permission) just as Corion and almut reported. If you can't edit your webserver, you're out of luck. Unless you can drop CGIs in a specified dir for execution. That's a typical setup.

Re: Question on CGI-PERL
by almut (Canon) on Mar 03, 2010 at 20:10 UTC
    I place bot html & corresponding CGI code in /var/www/html directory

    CGI scripts typically go in a cgi-bin directory (which is set up to run the scripts instead of sending out the source code)... But ultimately, it's a question of how the web server is configured.

Re: Question on CGI-PERL
by toolic (Bishop) on Mar 03, 2010 at 20:07 UTC