summaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-08-14 05:47:29 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-08-14 05:47:29 +0000
commit922e6ec144f5b831c38683b7ae84ab6e04054cb6 (patch)
tree36472962e036f9fe60c8add37ddc40b3ba8cfe69 /IkiWiki.pm
parentb4dafe467be5f6c885204887aeae2f4d513b3640 (diff)
the perl critic reminded me that the library shouldn't be using IN and OUT
global file handles
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r--IkiWiki.pm32
1 files changed, 16 insertions, 16 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 37c73cb9f..6b74bf08a 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -292,11 +292,11 @@ sub readfile ($;$$) { #{{{
}
local $/=undef;
- open (IN, $file) || error("failed to read $file: $!");
- binmode(IN) if ($binary);
- return \*IN if $wantfd;
- my $ret=<IN>;
- close IN || error("failed to read $file: $!");
+ open (my $in, $file) || error("failed to read $file: $!");
+ binmode($in) if ($binary);
+ return \*$in if $wantfd;
+ my $ret=<$in>;
+ close $in || error("failed to read $file: $!");
return $ret;
} #}}}
@@ -331,15 +331,15 @@ sub writefile ($$$;$$) { #{{{
}
my $cleanup = sub { unlink($newfile) };
- open (OUT, ">$newfile") || error("failed to write $newfile: $!", $cleanup);
- binmode(OUT) if ($binary);
+ open (my $out, '>', $newfile) || error("failed to write $newfile: $!", $cleanup);
+ binmode($out) if ($binary);
if ($writer) {
- $writer->(\*OUT, $cleanup);
+ $writer->(\*$out, $cleanup);
}
else {
- print OUT $content or error("failed writing to $newfile: $!", $cleanup);
+ print $out $content or error("failed writing to $newfile: $!", $cleanup);
}
- close OUT || error("failed saving $newfile: $!", $cleanup);
+ close $out || error("failed saving $newfile: $!", $cleanup);
rename($newfile, "$destdir/$file") ||
error("failed renaming $newfile to $destdir/$file: $!", $cleanup);
} #}}}
@@ -787,8 +787,8 @@ sub enable_commit_hook () { #{{{
} #}}}
sub loadindex () { #{{{
- open (IN, "$config{wikistatedir}/index") || return;
- while (<IN>) {
+ open (my $in, "$config{wikistatedir}/index") || return;
+ while (<$in>) {
$_=possibly_foolish_untaint($_);
chomp;
my %items;
@@ -815,7 +815,7 @@ sub loadindex () { #{{{
$oldrenderedfiles{$page}=[@{$items{dest}}];
$pagectime{$page}=$items{ctime}[0];
}
- close IN;
+ close $in;
} #}}}
sub saveindex () { #{{{
@@ -826,7 +826,7 @@ sub saveindex () { #{{{
}
my $newfile="$config{wikistatedir}/index.new";
my $cleanup = sub { unlink($newfile) };
- open (OUT, ">$newfile") || error("cannot write to $newfile: $!", $cleanup);
+ open (my $out, '>', $newfile) || error("cannot write to $newfile: $!", $cleanup);
foreach my $page (keys %pagemtime) {
next unless $pagemtime{$page};
my $line="mtime=$pagemtime{$page} ".
@@ -838,9 +838,9 @@ sub saveindex () { #{{{
if (exists $depends{$page}) {
$line.=" depends=".encode_entities($depends{$page}, " \t\n");
}
- print OUT $line."\n" || error("failed writing to $newfile: $!", $cleanup);
+ print $out $line."\n" || error("failed writing to $newfile: $!", $cleanup);
}
- close OUT || error("failed saving to $newfile: $!", $cleanup);
+ close $out || error("failed saving to $newfile: $!", $cleanup);
rename($newfile, "$config{wikistatedir}/index") ||
error("failed renaming $newfile to $config{wikistatedir}/index", $cleanup);
} #}}}