This replaces a few occurrences of ugly code with a more clean and
idiomatic usage. The problem was highlighted by perlcritic, but we're
not enforcing the policy that led to the discovery.
Discussion: https://postgr.es/m/
20200412074245.GB623763@rfd.leadboat.com
{
my $filename = shift;
my $F;
- my $t = $/;
-
- undef $/;
+ local $/ = undef;
open($F, '<', $filename) || die "Could not open file $filename\n";
my $txt = <$F>;
close($F);
- $/ = $t;
return $txt;
}
{
my $filename = shift;
my $F;
- my $t = $/;
-
- undef $/;
+ local $/ = undef;
open($F, '<', $filename) || croak "Could not open file $filename\n";
my $txt = <$F>;
close($F);
- $/ = $t;
return $txt;
}
{
my $reldir = shift;
my $F;
- my $t = $/;
-
- undef $/;
+ local $/ = undef;
open($F, '<', "$reldir/GNUmakefile")
|| open($F, '<', "$reldir/Makefile")
|| confess "Could not open $reldir/Makefile\n";
my $txt = <$F>;
close($F);
- $/ = $t;
return $txt;
}
# Fetch all timezones currently in the file
#
my @file_zones;
+my $pgtz;
open(my $tzfh, '<', $tzfile) or die "Could not open $tzfile!\n";
-my $t = $/;
-undef $/;
-my $pgtz = <$tzfh>;
+{
+ local $/ = undef;
+ $pgtz = <$tzfh>;
+}
close($tzfh);
-$/ = $t;
# Attempt to locate and extract the complete win32_tzmap struct
$pgtz =~ /win32_tzmap\[\] =\s+{\s+\/\*[^\/]+\*\/\s+(.+?)};/gs