PDA

View Full Version : Importing of user-defined package returns an error


bruce
08-09-2004, 01:28 AM
try put your .pm file in your root directory. i think perl is rather dumb and will not look for the .pm file in the same directory.


[b]quote:Originally posted by laoyezhao

Dear Sir/Madam:

I have a very simple testing perl web application deployed on the server, when I execute the application the following error is displayed on the browser:

"The specified CGI application misbehaved by not returning a complete set of HTTP headers"

URL: http://sellthat.net/cgi-bin/yong/index.pl

This application could run correctly on my own windows based machine.
I have only two .pl files in this application as follow:

1) index.pl:
use mypackage;#this line invokes the error
use warnings;
use CGI qw(:all);
use CGI::Carp "fatalsToBrowser";

# call the subroutine in the imported mypackage
#display();

print header(),
start_html({-title=>'This is a testing'}),
center(b('Testing of perl web applications')),
end_html();
> ---------------------------------------

# this is my user-defined package
2) mypackage.pm:
package mypackage;

use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(&display);
use warnings;
use CGI qw(:all);
use CGI::Carp "fatalsToBrowser";

sub display()
{
# do something here
}
return 1;
-----------------------------------------------
If I remove the first line "use mypackage" from the above index.pl file, the error is gone.

Any comments will be highly appreciated!

Yong




yong
</blockquote id="quote"></font id="quote">

B.

DiscountASP.NET
http://www.DiscountASP.NET

laoyezhao
08-09-2004, 11:40 AM
Dear Sir/Madam:

I have a very simple testing perl web application deployed on the server, when I execute the application the following error is displayed on the browser:

"The specified CGI application misbehaved by not returning a complete set of HTTP headers"

URL: http://sellthat.net/cgi-bin/yong/index.pl

This application could run correctly on my own windows based machine.
I have only two .pl files in this application as follow:

1) index.pl:
use mypackage;#this line invokes the error
use warnings;
use CGI qw(:all);
use CGI::Carp "fatalsToBrowser";

# call the subroutine in the imported mypackage
#display();

print header(),
start_html({-title=>'This is a testing'}),
center(b('Testing of perl web applications')),
end_html();
> ---------------------------------------

# this is my user-defined package
2) mypackage.pm:
package mypackage;

use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(&display);
use warnings;
use CGI qw(:all);
use CGI::Carp "fatalsToBrowser";

sub display()
{
# do something here
}
return 1;
-----------------------------------------------
If I remove the first line "use mypackage" from the above index.pl file, the error is gone.

Any comments will be highly appreciated!

Yong




yong