From 3b10c53163ee3417b0607078c71708627392ba45 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Sat, 12 Nov 2022 22:17:17 -0600 Subject: [PATCH] Change storage of other mode flags to constants This eliminates the global variables previously used to indicate if the --help and/or --version flags had been specified and allows the relevant conditionals to be resolved during the compilation phase. --- gatekeeper.pl | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index d5b8a77..def6114 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -210,14 +210,10 @@ my $URL = "http://www.gnu.org/prep/maintain/html_node/Automated-FTP-Uploads.html"; BEGIN { - # These must be declared "our" so that the actual variable with the data - # (in the symbol table) will remain available after the BEGIN block. - # - # These should be changed to constants eventually, since they should not - # change after the script is started. my $ZONE = ''; - our $help = ''; - our $version = ''; + my $want_help = ''; + my $want_version = ''; + # Set this to 1 or higher to get debug output in the log file. my $DEBUG = 1; @@ -229,8 +225,8 @@ BEGIN { my $TestingMode = 0; - GetOptions('help' => \$help, - 'version' => \$version, + GetOptions('help' => \$want_help, + 'version' => \$want_version, 'zone|z|s=s' => \$ZONE, 'tstampcheck=i' => \$TSTAMPCHECK, 'nomail=i' => \$NOMAIL, @@ -243,6 +239,9 @@ BEGIN { constant->import(NOMAIL => $NOMAIL); constant->import(TSTAMPCHECK => $TSTAMPCHECK); + constant->import(WANT_HELP => $want_help); + constant->import(WANT_VERSION => $want_version); + constant->import(IN_TEST_MODE => $TestingMode); if ($TestingMode) { @@ -261,10 +260,7 @@ BEGIN { } } -our $help; -our $version; - -if ($version) { +if (WANT_VERSION) { print "\nThis is $NAME protocol version $VERSION ($DATE)\n"; print $COPYRIGHT_NOTICE; print "License: $LICENSE\n"; @@ -277,7 +273,7 @@ if ($version) { exit 0; } -pod2usage(-verbose => 1, -exitval => 0) if ($help); +pod2usage(-verbose => 1, -exitval => 0) if WANT_HELP; pod2usage(-message => 'ERROR: Required parameter not given or invalid.', -verbose => 0, -exitval => 2) if ((ZONE ne 'ftp') && (ZONE ne 'alpha') && (ZONE ne 'distros')); -- 2.25.1