sub output { my $self = shift; # mod_perl 2.x if ( $ENV{MOD_PERL} ) { eval { require Apache::IO; Apache::IO->import; }; if ($@) { die "Cannot figure out what to do under Apache!\n"; } tie *XLS, 'Apache::IO'; binmode *XLS; return $self->write_file(\*XLS); } # mod_perl 1.x (or CGI under mod_perl 2.x) elsif ( $ENV{GATEWAY_INTERFACE} ) { my $module_name; eval { require Apache; Apache->import; $module_name = 'Apache'; }; if ($@) { die "Cannot figure out what to do under Apache!\n"; } tie *XLS, $module_name; binmode *XLS; return $self->write_file(\*XLS); } # CGI (or non-WWW) behavior else { $self->write_file('-'); } }