Mailing List Archive

Output Filehandle
I am trying to use Text::xSV to output tab seperated data to the browser
(actually a Wyncs plugin). The xSV module can output to STDOUT or any
other File Handle. When I try to use STDOUT, the text doesn't show up.
Is there some other file handle I should use?

Thanks,
Stuart Johnston

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org
Re: Output Filehandle [ In reply to ]
Stuart Johnston wrote:
> I am trying to use Text::xSV to output tab seperated data to the browser
> (actually a Wyncs plugin). The xSV module can output to STDOUT or any
> other File Handle. When I try to use STDOUT, the text doesn't show up.
> Is there some other file handle I should use?
>

No exactly, Apache::ASP does a select() to redirect print() calls
to a RESPONSE file handle really tied to the $Response object.

You could try something like this:

tie *RESPONSE, 'Apache::ASP::Response', $self->{Response};
print RESPONSE ...

or even using *Apache::ASP::RESPONSE directly...

BUT I would really not recommend this approach as there are no
guarantees in the Apache::ASP API for this method to exist.

What you should do is simply write this out to a temp file and
then output that directly to the browser after its created
by reading it in, and writing it using $Response->Write.

Regards,

Josh
________________________________________________________________________
Josh Chamas, Founder | NodeWorks - http://www.nodeworks.com
Chamas Enterprises Inc. | NodeWorks Directory - http://dir.nodeworks.com
http://www.chamas.com | Apache::ASP - http://www.apache-asp.org


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org
RE: Output Filehandle [ In reply to ]
Or, if you're running a sufficiently recent version of perl, you can use

open HANDLE, '>', \$somevar;
#call xSV here
close HANDLE;

$Response->Write($somevar);

Bascially, you open a handle to an in-memory variable to write to. This
saves having to use a temp file. I know 5.8.0 supports this. Not sure
if it's in any of the 5.6.X versions.

--Jim

> -----Original Message-----
> From: Josh Chamas [mailto:josh@chamas.com]
> Sent: Monday, May 24, 2004 3:59 PM
> To: Stuart Johnston
> Cc: Apache-ASP List
> Subject: Re: Output Filehandle
>
>
> Stuart Johnston wrote:
> > I am trying to use Text::xSV to output tab seperated data
> to the browser
> > (actually a Wyncs plugin). The xSV module can output to
> STDOUT or any
> > other File Handle. When I try to use STDOUT, the text
> doesn't show up.
> > Is there some other file handle I should use?
> >
>
> No exactly, Apache::ASP does a select() to redirect print() calls
> to a RESPONSE file handle really tied to the $Response object.
>
> You could try something like this:
>
> tie *RESPONSE, 'Apache::ASP::Response', $self->{Response};
> print RESPONSE ...
>
> or even using *Apache::ASP::RESPONSE directly...
>
> BUT I would really not recommend this approach as there are no
> guarantees in the Apache::ASP API for this method to exist.
>
> What you should do is simply write this out to a temp file and
> then output that directly to the browser after its created
> by reading it in, and writing it using $Response->Write.
>
> Regards,
>
> Josh
> ______________________________________________________________
> __________
> Josh Chamas, Founder | NodeWorks - http://www.nodeworks.com
> Chamas Enterprises Inc. | NodeWorks Directory -
http://dir.nodeworks.com
http://www.chamas.com | Apache::ASP - http://www.apache-asp.org


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org