Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.