Commit 8f00d84a authored by Andrew Dunstan's avatar Andrew Dunstan

Use perl's $/ more idiomatically

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
parent 7be5d8df
...@@ -762,13 +762,10 @@ sub read_file ...@@ -762,13 +762,10 @@ sub read_file
{ {
my $filename = shift; my $filename = shift;
my $F; my $F;
my $t = $/; local $/ = undef;
undef $/;
open($F, '<', $filename) || die "Could not open file $filename\n"; open($F, '<', $filename) || die "Could not open file $filename\n";
my $txt = <$F>; my $txt = <$F>;
close($F); close($F);
$/ = $t;
return $txt; return $txt;
} }
......
...@@ -420,13 +420,10 @@ sub read_file ...@@ -420,13 +420,10 @@ sub read_file
{ {
my $filename = shift; my $filename = shift;
my $F; my $F;
my $t = $/; local $/ = undef;
undef $/;
open($F, '<', $filename) || croak "Could not open file $filename\n"; open($F, '<', $filename) || croak "Could not open file $filename\n";
my $txt = <$F>; my $txt = <$F>;
close($F); close($F);
$/ = $t;
return $txt; return $txt;
} }
...@@ -435,15 +432,12 @@ sub read_makefile ...@@ -435,15 +432,12 @@ sub read_makefile
{ {
my $reldir = shift; my $reldir = shift;
my $F; my $F;
my $t = $/; local $/ = undef;
undef $/;
open($F, '<', "$reldir/GNUmakefile") open($F, '<', "$reldir/GNUmakefile")
|| open($F, '<', "$reldir/Makefile") || open($F, '<', "$reldir/Makefile")
|| confess "Could not open $reldir/Makefile\n"; || confess "Could not open $reldir/Makefile\n";
my $txt = <$F>; my $txt = <$F>;
close($F); close($F);
$/ = $t;
return $txt; return $txt;
} }
......
...@@ -60,12 +60,13 @@ $basekey->Close(); ...@@ -60,12 +60,13 @@ $basekey->Close();
# Fetch all timezones currently in the file # Fetch all timezones currently in the file
# #
my @file_zones; my @file_zones;
my $pgtz;
open(my $tzfh, '<', $tzfile) or die "Could not open $tzfile!\n"; open(my $tzfh, '<', $tzfile) or die "Could not open $tzfile!\n";
my $t = $/; {
undef $/; local $/ = undef;
my $pgtz = <$tzfh>; $pgtz = <$tzfh>;
}
close($tzfh); close($tzfh);
$/ = $t;
# Attempt to locate and extract the complete win32_tzmap struct # Attempt to locate and extract the complete win32_tzmap struct
$pgtz =~ /win32_tzmap\[\] =\s+{\s+\/\*[^\/]+\*\/\s+(.+?)};/gs $pgtz =~ /win32_tzmap\[\] =\s+{\s+\/\*[^\/]+\*\/\s+(.+?)};/gs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment