Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to create a Perl module to be used in a CGI script

Reply
Thread Tools

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

 
 
James
Guest
Posts: n/a
 
      08-15-2003
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
 
Reply With Quote
 
 
 
 
David Efflandt
Guest
Posts: n/a
 
      08-16-2003
On 15 Aug 2003 10:52:03 -0700, James <(E-Mail Removed)> wrote:
> 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.

--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
what's wrong calling a Perl/CGI script in Perl/CGI script under Tomcat server? kath Perl Misc 4 04-09-2007 09:21 PM
perl/cgi exploit with bracketed module names passed in as CGI param shumsta Perl Misc 1 07-21-2005 11:30 PM
CGI: Execute a perl script inside another perl script xdarcos@hotmail.com Perl Misc 20 01-18-2005 12:33 PM
CGI module: getting cgi params from text file redirected to script run on the commandline fatted Perl Misc 1 07-25-2003 01:44 AM



Advertisments