Jump to content

[SOLVED] perl not working


Recommended Posts

#!d:/xampp/perl/bin/perl.exe
# ^^^ this must be the first line of the script! ^^^
# start code


# print header and start the markup output

print 'hello';
# end code

does not work (returns server error).

 

#!d:/xampp/perl/bin/perl.exe
# ^^^ this must be the first line of the script! ^^^
# start code

use strict;
use CGI;
my $q = new CGI;

# print header and start the markup output

print $q->header( "text/html" ),$q->start_html( "hello from perl cgi!" );
print $q->h2("Hello World!");
print $q->end_html;
# end code

This works.  Why do I have to do it OOP Like this instead of standard perl.

I have downloaded activeperl from there website and modified my "apache" config files to

do what they need to do (for pl and cgi files).

Now that it's done.  I have basically 3 questions.

 

1. What is the reason behind one form of coding working, and another not (as explained above).

 

2. What is the difference between Perl in CGI and Mod_perl.  Are they inherently different, or does the

syntax/functionality of them change.

 

3. Which one am I most likely to encounter during a standard development project, cgi mode, or Mod_perl in

apache.

 

There is also something in php called php perl, is this something else or just another form of mod_perl with the

same syntax?

Link to comment
https://forums.phpfreaks.com/topic/74009-solved-perl-not-working/
Share on other sites

I have no idea why you're getting an error unless Apache requires you to use CGI. What does Apache's error log have to say about it?

 

I've heard mod_perl is better; however, I've never used Perl with Apache, so you might want to ask your question at perlmonks.net.

I don't understand but it's doing it on both my server at 1and1 and my local machine.

The normal one doesn't work the longer one does.  Apache returns just header error when I am running the

script.  When I run it with all that OOP code it works fine.  It is rather strange.

Well the second bit of code you posted sends a header, so I'm assuming this is required. This could be a Perl thing, or an Apache configuration issue. I would use CGI; since it seems to handle much of the work for you. If want to go the other route, try sending a header.

effigy is right -- your comment says you're going to print a header, but you don't... the following should work.

 

#!d:/xampp/perl/bin/perl.exe
# ^^^ this must be the first line of the script! ^^^
# start code


# print header and start the markup output
print "Content-Type: text/html\n\n";
print 'hello';
# end code

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.