Subject: | Crash when source being formatted has PerlTidy warnings |
1) Install Test::Base
2) Fire up your Pod::Webserver::Source program.
3) Try to look at the source for Test::Base.
Server dies with "Couldn't open
file:/usrlib/perl5/site_perl/5.6.1/Test/Base.pm.ERR in mode:w :
Permission denied". This is because Test::Base gets formatting warnings
when run through PerlTidy.
Solution: Pass a temp file to the PerlTidy call for errfile. The
diagnostics can successfully be written to this file, and the output
comes out okay.
--- /home/y/lib/perl5/site_perl/5.8/Pod/Webserver/Source.pm.tmp Fri May 27 13:43:09 2005
+++ /home/y/lib/perl5/site_perl/5.8/Pod/Webserver/Source.pm Wed Jul 13 14:32:13 2005
@@ -2,6 +2,8 @@
# $Id: Source.pm,v 1.1 2005/01/05 12:26:39 cwest Exp $
use strict;
use vars qw[$LINK_PATH $PERLTIDY_ARGV $VERSION];
+use File::Temp;
+
$PERLTIDY_ARGV = [qw[-html -npod -nnn]];
$VERSION = sprintf "%d.%02d", split m/\./, (qw$Revision: 1.1 $)[1];
@@ -64,11 +66,14 @@
my ($self, $fspath, $resp) = @_;
my $output = '';
+ my $temp = new File::Temp;
+ my $errorfile = $temp->filename;
if ( eval { require Perl::Tidy } ) {
Perl::Tidy::perltidy(
source => $fspath,
destination => \$output,
argv => $Pod::Webserver::Source::PERLTIDY_ARGV,
+ errorfile => $errorfile,
);
} else {
$resp->header('Content-Type' => 'text/plain');