I'm using Apache server on Fedora-20. I'm trying to run a perl-cgi program on my local server, but it's not working, I have attached my html and perl code.

html program:

<form action="/cgi-bin/fam.cgi" method="post">
<input type="text" name="username">
<input type="submit">

This ran properly and outputs:

print "Content-type: text/html\n\n";
print "hello world\n";

But when I pass a parameter, it doesn't work.

#!usr/bin/perl -wT 
use CGI;
my $username = param('username');
print header;
print start_html("Perl page");
print h2("hello $username");
print end_html; 

I've already installed the cgi module. Any suggestions?


I think you have to add:

my $q = CGI->new();
my $username = $q->param('username');

So the whole should look like:

#!/usr/bin/perl -wT
use strict;
use warnings;
use CGI;

my $q = CGI->new();
my $username = $q->param('username');

print $q->header();
print $q->start_html("Perl page");
print $q->h2("Hello, $username!\n");
print $q->end_html;

More info you can here.
Also in your file you are missing "/":

#!usr/bin/perl -wT

I think should be:

#!/usr/bin/perl -wT
  • Its also is not working... Internal server error. I already change mod by using this command `chmod 755 filename' – Krithi.S Mar 24 '15 at 7:37
  • What is happening if run it from command line? – taliezin Mar 24 '15 at 7:42
  • Before failed complication aborted at line 6 – Krithi.S Mar 24 '15 at 7:47
  • Anything else, syntax error or whatever? – taliezin Mar 24 '15 at 7:57
  • there is no syntax error.. – Krithi.S Mar 24 '15 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.