You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Thomas Hilbig <th...@yahoo.com> on 2003/03/17 16:33:59 UTC

[MP2] Can't dup STDOUT

I need to dup the STDOUT handle for a package
(Spreadsheet::WriteExcel) to work properly under
mod_perl.
The code below from the MP1 User documentation now
gives an error in MP2:

      use constant IS_MODPERL => $ENV{MOD_PERL};
      if (IS_MODPERL) {
        tie *OUT, 'Apache';
      } else {
        open (OUT, ">-");
      }

Under MP2 I get the following error: Can't locate
object method "TIEHANDLE" via package "Apache"
Is there an updated method for doing this in MP2?
My environment is : mod_perl/1.99_05-dev, Apache
httpd-2.0.40-8, RedHat 8.0

Thanks, Tom


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com

Re: [MP2] Can't dup STDOUT

Posted by Nick Tonkin <ni...@tonkinresolutions.com>.
On Mon, 17 Mar 2003, Thomas Hilbig wrote:

> I need to dup the STDOUT handle for a package
> (Spreadsheet::WriteExcel) to work properly under
> mod_perl.
> The code below from the MP1 User documentation now
> gives an error in MP2:
>
>       use constant IS_MODPERL => $ENV{MOD_PERL};
>       if (IS_MODPERL) {
>         tie *OUT, 'Apache';
>       } else {
>         open (OUT, ">-");
>       }
>
> Under MP2 I get the following error: Can't locate
> object method "TIEHANDLE" via package "Apache"
> Is there an updated method for doing this in MP2?
> My environment is : mod_perl/1.99_05-dev, Apache
> httpd-2.0.40-8, RedHat 8.0

Given that mod_perl 2 is _beta_ software, you should be using the current
version. It's 1.99_09, and Apache is at 2.0.44. Try the following commands
to get the latest mod_perl sources so you can rebuild:

$ cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic login
$ cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic co modperl-2.0

You can get Apache 2.0.44 from the apache site. FWIW once you get the
current apache installed you can rebuild mod_perl more easily than mp1,
since it uses the already-built apache.

Now as for TIEHANDLE, you have not loaded the right module. Try reading
the docs about porting at
http://perl.apache.org/docs/2.0/devel/porting/porting.html and especially
the section on locating missing modules:

http://perl.apache.org/docs/2.0/devel/porting/porting.html#Figuring_Out_What_Modules_Need_to_be_Loaded

This will lead you to do:

$ perl -MApache2 -MModPerl::MethodLookup -le \
> 'print((ModPerl::MethodLookup::lookup_method(shift))[0])' \
> TIEHANDLE

which prints:

There is more than one class with method 'TIEHANDLE'
try one of:
        use Apache::RequestIO ();
        use Apache::Filter ();

>From there you could probably guess that the module you need to load is
Apache::RequestIO, right?

HTH,

- nick

-- 

~~~~~~~~~~~~~~~~~~~~
Nick Tonkin   {|8^)>