Skip to content

Commit 8f00d84

Browse files
committed
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
1 parent 7be5d8d commit 8f00d84

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

src/tools/msvc/Install.pm

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,13 +762,10 @@ sub read_file
762762
{
763763
my $filename = shift;
764764
my $F;
765-
my $t = $/;
766-
767-
undef $/;
765+
local $/ = undef;
768766
open($F, '<', $filename) || die "Could not open file $filename\n";
769767
my $txt = <$F>;
770768
close($F);
771-
$/ = $t;
772769

773770
return $txt;
774771
}

src/tools/msvc/Project.pm

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,10 @@ sub read_file
420420
{
421421
my $filename = shift;
422422
my $F;
423-
my $t = $/;
424-
425-
undef $/;
423+
local $/ = undef;
426424
open($F, '<', $filename) || croak "Could not open file $filename\n";
427425
my $txt = <$F>;
428426
close($F);
429-
$/ = $t;
430427

431428
return $txt;
432429
}
@@ -435,15 +432,12 @@ sub read_makefile
435432
{
436433
my $reldir = shift;
437434
my $F;
438-
my $t = $/;
439-
440-
undef $/;
435+
local $/ = undef;
441436
open($F, '<', "$reldir/GNUmakefile")
442437
|| open($F, '<', "$reldir/Makefile")
443438
|| confess "Could not open $reldir/Makefile\n";
444439
my $txt = <$F>;
445440
close($F);
446-
$/ = $t;
447441

448442
return $txt;
449443
}

src/tools/win32tzlist.pl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@
6060
# Fetch all timezones currently in the file
6161
#
6262
my @file_zones;
63+
my $pgtz;
6364
open(my $tzfh, '<', $tzfile) or die "Could not open $tzfile!\n";
64-
my $t = $/;
65-
undef $/;
66-
my $pgtz = <$tzfh>;
65+
{
66+
local $/ = undef;
67+
$pgtz = <$tzfh>;
68+
}
6769
close($tzfh);
68-
$/ = $t;
6970

7071
# Attempt to locate and extract the complete win32_tzmap struct
7172
$pgtz =~ /win32_tzmap\[\] =\s+{\s+\/\*[^\/]+\*\/\s+(.+?)};/gs

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy