James Taylor wrote: > I posted this to the mod_perl list 2 days ago, but it seems a bit > inappropriate there as the discussion is much more > advanced than my question... That and I haven't gotten a response, so > sorry for the crosspost :) > > I'm running apache 1.3.x with the associated version of mod_perl, but > am having trouble creating regular old include > files to be used with helper functions. Works just great with regular > old CGI, mod_perl doesn't like it. Say for example I have two files, > main.pl and helper.pl. > > # helper.pl > sub dowhatever() { # this is completely pointless, i'm just using it > as an example > my [EMAIL PROTECTED]; my $p; > foreach my $k(sort keys %params) { $k =~ s/'$//g; $p.=$k; } > return $p; > } > 1; > > # main.pl > #!/usr/bin/perl > use strict; > use Apache::Constants qw(OK DECLINED SERVER_ERROR FORBIDDEN); > use Apache::Cookie (); > require('helper.pl'); > > #..............some stuff > my $q=&dowhatever(%somehash); > > > That doesn't work in the least, I keep getting errors in my apache > logs saying sub dowhatever is an undefined function, etc. Is it > possible to even do anything like this in mod_perl, or do I need to > write an Apache module / Perl Module just to have helper functions in > there?
FWIW, That example works OK for me under Apache 1.3.31, mod_perl 1.29 when I run under Apache::Registry. I had to add a declaration for %somehash, but otherwise it runs without error. Is main.pl running under Apache::Registry, or is it a PerlHandler or some other type of handler? It always makes me nervous to see assumptions about the current working directory in any web server stuff. You should code the full path to helper.pl, or better, create a proper module and pull it in with use. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>