Thanks Tom. It works now. I forgot "/" between r->document_root() and "templates/quickquote.templ".
Great help! Willy -----Original Message----- From: Huilli Liu [mailto:[EMAIL PROTECTED] Sent: Thursday, June 17, 2004 10:40 AM To: Tom Schindl Cc: [EMAIL PROTECTED] Subject: RE: IO::File problem on Mod_perl Thanks Tom. I made a simple case for this issue but as a result of the test, it still doesn't work. So I think it may something to do Mod_perl and IO::File. I am running: Apache/2.0.46 (Win32) mod_perl/1.99_10-dev Perl/v5.8.0 PHP/4.3.2 mod_ssl/2.0.46 OpenSSL/0.9.7b Server at mydomain Port 8080 #file:MyApache/template_test.pm #---------------------- package MyApache::template_test; use strict; use warnings; use IO::File; use Apache::RequestRec (); use Apache::RequestIO (); use Apache::Const -compile => qw(OK); use Apache::RequestUtil (); sub handler { my $r = shift; $r->content_type('text/plain'); my $template_file = new IO::File($r->document_root()."templates/quickquote.templ"); $template_file->input_record_separator(undef); my $template = <$template_file>; $template_file->close; print $template; return Apache::OK; } 1; In conf/perl.conf <Location /template_test> SetHandler perl-script PerlResponseHandler MyApache::template_test </Location> Regards, Willy -----Original Message----- From: Tom Schindl [mailto:[EMAIL PROTECTED] Sent: Thursday, June 17, 2004 2:35 AM To: Huilli Liu Cc: [EMAIL PROTECTED] Subject: Re: IO::File problem on Mod_perl Huilli Liu wrote: > Hi All, > > Recently I are migrating cgi to mod_perl but it is running out of the > problem for IO::File. > Here are my original codes: > Try it like this: ---------------------8<--------------------- use Apache::RequestUtil (); $template_file = new IO::File($r->document_root()."templates/quickquote.templ"); --------------------->8--------------------- mp2 does not chdir because chdir will affect all threads!!! http://perl.apache.org/docs/2.0/user/coding/coding.html#Thread_environme nt_Issues Tom > my $template_file = new IO::File("templates/quickquote.templ"); > $template_file->input_record_separator(undef); > my $template = <$template_file>; > $template_file->close; > > "templates/quickquote.templ" is under "DocumentRoot" directory but it > looks like it can not find the file. > > The error I got is as below: > > [Wed Jun 16 16:52:46 2004] [error] [client 10.5.20.105] Can't call > method "input_record_separator" on an undefined value at > c:/Apache2/modperl/MyApache/StockList.pm line 628. > , referer: http://localhost:8080/stocklist > > Is there anyone who has the experience for this problem? > Please give me some advices if you know how to fix it. > > Thanks, > > Willy > > Reclaim Your Inbox! http://www.mozilla.org/products/thunderbird -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html