Custom PM Modules Won"t Work
Custom PM Modules Won"t Work
am 03.05.2006 01:17:02 von Rob
Hello
I have written a website using Perl which runs in IIS and I now want to
divide the functionality into modules but as soon as I try I get the error
"The CGI Application Missbehaved"
Can someone give me a simple example Perl script that uses a module so I can
test to see if this is a server issue and can anyone recommend a way to fix
this?
I have tried both Use and Require with the same results
Thanks
Rob
Re: Custom PM Modules Won"t Work
am 03.05.2006 03:31:01 von Sisyphus
"Rob" wrote in message
news:OLR5g.1170$LU3.898@newsfe2-gui.ntli.net...
> Hello
>
> I have written a website using Perl which runs in IIS and I now want to
> divide the functionality into modules but as soon as I try I get the error
> "The CGI Application Missbehaved"
> Can someone give me a simple example Perl script that uses a module so I
can
> test to see if this is a server issue and can anyone recommend a way to
fix
> this?
>
> I have tried both Use and Require with the same results
>
> Thanks
> Rob
The module (Foo.pm):
---------------------------------------
package Foo;
#require Exporter;
#@ISA = qw(Exporter);
#@EXPORT = qw(greeting);
sub greeting {
print "Hello from foo\n";
}
1;
---------------------------------------
The script that uses Foo.pm:
---------------------------------------
use warnings;
use Foo;
Foo::greeting();
---------------------------------------
If, in Foo.pm, you include the code that is currently commented out, then
the script could be changed to:
---------------------------------------
use warnings;
use Foo;
greeting();
---------------------------------------
See 'perldoc Exporter' for more info and other (better) options regarding
export of functions from modules.
Cheers,
Rob
Re: Custom PM Modules Won"t Work
am 03.05.2006 08:11:05 von Rob
Thanks
This works in a command prompt but won't work in a web script in IIS with
the CGI module also loaded
It says
CGI Error
The specified CGI application misbehaved by not returning a complete set of
HTTP headers.
Is it a permisions problem on the directory?
Or is Perl not looking in the same directory as the script for .pm files?
Thanks
Rob
"Sisyphus" wrote in message
news:4458089e$0$14494$afc38c87@news.optusnet.com.au...
>
> "Rob" wrote in message
> news:OLR5g.1170$LU3.898@newsfe2-gui.ntli.net...
>> Hello
>>
>> I have written a website using Perl which runs in IIS and I now want to
>> divide the functionality into modules but as soon as I try I get the
>> error
>> "The CGI Application Missbehaved"
>> Can someone give me a simple example Perl script that uses a module so I
> can
>> test to see if this is a server issue and can anyone recommend a way to
> fix
>> this?
>>
>> I have tried both Use and Require with the same results
>>
>> Thanks
>> Rob
>
> The module (Foo.pm):
> ---------------------------------------
> package Foo;
>
> #require Exporter;
> #@ISA = qw(Exporter);
> #@EXPORT = qw(greeting);
>
> sub greeting {
> print "Hello from foo\n";
> }
>
> 1;
> ---------------------------------------
>
> The script that uses Foo.pm:
> ---------------------------------------
> use warnings;
> use Foo;
> Foo::greeting();
> ---------------------------------------
>
> If, in Foo.pm, you include the code that is currently commented out, then
> the script could be changed to:
> ---------------------------------------
> use warnings;
> use Foo;
> greeting();
> ---------------------------------------
>
> See 'perldoc Exporter' for more info and other (better) options regarding
> export of functions from modules.
>
> Cheers,
> Rob
>
>
Re: Custom PM Modules Won"t Work
am 03.05.2006 13:13:51 von nobull67
Rob spits TOFU in our faces:
[please don't]
> [...] is Perl not looking in the same directory as the script for .pm files?
Perl does not do this by default. If you are sure that you want it to,
see the solution given in the FAQ. But it's probably better to stop
wanting to.
Re: Custom PM Modules Won"t Work
am 04.05.2006 00:22:00 von Rob
Thanks
I've got it now
FAQs are wonderful things!
I had to add this to the top of the main page and now everything is sorted:
use FindBin;
use lib "$FindBin::Bin";
Thanks
Rob
"Brian McCauley" wrote in message
news:1146654831.454140.194800@v46g2000cwv.googlegroups.com.. .
>
> Rob spits TOFU in our faces:
>
> [please don't]
>
>> [...] is Perl not looking in the same directory as the script for .pm
>> files?
>
> Perl does not do this by default. If you are sure that you want it to,
> see the solution given in the FAQ. But it's probably better to stop
> wanting to.
>