> I have searched through the archives for an answer and have found a lot of
> discussion, but nothing concrete enough to help ...
> 
> I am using Spreadsheet::WriteExcel to create an Excel doc (hence the name)
> but I keep getting blank documents back.
> 
> The module can write to a file or to STDOUT using '-'. From the archives I
> see that this is similar to an issue with Apache::Magick where the C STDOUT
> (expressed as '-' or '>-') is different from Perl's default STDOUT.
> 
> I have also tried the code from the mod_perl guide:
>       use constant IS_MODPERL => $ENV{MOD_PERL};
>       if (IS_MODPERL) {
>         tie *OUT, 'Apache';
>       } else {
>         open (OUT, ">-");
>       }

I should kill this example, or provide more explanation. People are just
copy-n-paste examples without thinking too much

> Thanks for any help ... I know I am missing something obvious ...

This item will show up in the next version of the Guide:

=head1 Redirecting STDOUT into a String

Sometimes you have a situation where a black box functions prints the
output to C<STDOUT> and you want to get this output into a
string. This is just as valid under mod_perl, where you want the
C<STDOUT> to be tied to the C<Apache> object. So that's where the
C<IO::String> package comes to help. You can re-tie() the STDOUT (or
any other filehandler to a string) by doing a simple select() on the
C<IO::String> object and at the end to re-tie() the STDOUT back to its
original stream:

  my $str;
  my $str_fh = IO::String->new($str);
  my $old_fh = select($str_fh);
  
  # some function that prints to currently selected file handler.
  print_stuff()
  
  # reset default fh to previous value
  select($old_fh) if defined $old_fh;



_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://logilune.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/  


Reply via email to