perl - Open filehandle not working under mod_perl ModPerl::PerlRun -


i'm @ first attempt use mod_perl. i'm totally new it. opted modperl::perlrun because don't want make modification scripts have

i followed instructions in installing apache2/modperl on ubuntu 12.04

i uploaded script.pl /perl, , script looks like it's running fine except this

open(my $fh, '<:encoding(utf-8)', 'page_template.htm') or die $!; 

it won't open file , dies message

no such file or directory @ /var/www/perl/script.pl 

update

note the documentation modperl::perlrun has say

meta: document don't chdir() script's dir, because affects whole process under threads.

so not workable chdir in program's code, , second option below should used


original*

the current working directory of cgi program isn't think. tbe root directory /

you can either use chdir set working directory of script

use file::basename 'dirname'; chdir dirname(__file__); 

or add full path name of file want open, instance

open $fh, '<:encoding(utf-8)', '/perl/page_template.htm' or die $!; 

note can't use findbin, program being run subroutine of apache's main mod_perl process, $findbin::bin equal directory of apache executable httpd , not of own program file


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -