How to create a Perl module to be used in a CGI script

J

James

Hi,

I have the following:

filename: Module1.pm

package Module1;

BEGIN {
use Exporter();
@ISA = qw(Exporter);
@EXPORT = qw(&subroutine1);
}

sub subroutine1 {print "Hello!\n";}
return 1;
END { }
---------------------------------------------------
Filename: Trial.cgi running in Tomcat 4.1.27

#!c:\Perl\bin\perl.exe

use CGI
use Module1;

subroutine1();
..
..
..
..


When I run the script from my html page it asks for a file download. What am
I doing wrong?

Thanks, James
 
D

David Efflandt

Hi,

I have the following:

filename: Module1.pm

package Module1;

BEGIN {
use Exporter();
@ISA = qw(Exporter);
@EXPORT = qw(&subroutine1);
}

sub subroutine1 {print "Hello!\n";}
return 1;
END { }
---------------------------------------------------
Filename: Trial.cgi running in Tomcat 4.1.27

#!c:\Perl\bin\perl.exe

use CGI
use Module1;

subroutine1();
.
.
.
.


When I run the script from my html page it asks for a file download. What am
I doing wrong?

Besides forgetting to output a Content-type header followed by a blank
line (unless your server somehow guesses that), I suspect you are using
MSIE, which does not necessarily pay attention to MIME headers anyway.
So it guesses based on its own criteria, which might include filename
extension of the script. If that filename extension is associated with
Perl.exe, it considers that insecure and asks if you want to download or
execute it (not that you would have normally much luck executing CGI
output).

Note that MSIE considers "Content-type: text/plain" to be ambiguous (since
it often a default for unknown filetypes), and would go through its
guessing game for any text/plain content.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top