From 7d9188c6fa64c5f6c350ae1228395e03c531d6d0 Mon Sep 17 00:00:00 2001 From: Dan Church Date: Mon, 4 Sep 2023 10:50:30 -0500 Subject: [PATCH] Require Perl 5.12 Fix some postfix 'if' statements too. --- make-block.pl | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/make-block.pl b/make-block.pl index f778e4d..9c572d2 100755 --- a/make-block.pl +++ b/make-block.pl @@ -13,7 +13,7 @@ # You may NOT use this software for commercial purposes. ############################################################################### -use strict; +use 5.012; use warnings; use Getopt::Long qw/ GetOptions :config no_ignore_case /; @@ -27,7 +27,9 @@ sub add_domain_list { my $file = shift; foreach my $line (read_stripped($file)) { my $domain = lc $line; - ++$dupes if defined $domains{$domain}; + if (defined $domains{$domain}) { + ++$dupes; + } $domains{$domain} = 1; } } @@ -47,7 +49,9 @@ sub add_host_file { next; } my $domain = lc $parts[1]; - ++$dupes if defined $domains{$domain}; + if (defined $domains{$domain}) { + ++$dupes; + } $domains{$domain} = 1; } } @@ -117,7 +121,13 @@ MAIN: { printf STDERR "%d domains written to %s from\n", $written, $out // 'STDOUT'; printf STDERR " - %d .domains files\n", (scalar @domain_lists); printf STDERR " - %d .hosts files\n", (scalar @hosts_lists); - printf STDERR "(%d duplicates)\n", $dupes if $dupes; - printf STDERR "(%d domains removed via allowlist)\n", $removed_allowed if $removed_allowed; - printf STDERR "(%d skipped)\n", $skip if $skip; + if ($dupes) { + say STDERR "($dupes duplicates)"; + } + if ($removed_allowed) { + say STDERR "($removed_allowed domains removed via allowlist)"; + } + if ($skip) { + say STDERR "($skip skipped)"; + } }