summaryrefslogtreecommitdiffstats
path: root/lib/Monitoring/Plugin/Getopt.pm
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-12-16 13:08:44 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-12-16 13:08:44 +1300
commit40d5fbea30c310004233ef4cd3e570c351c54233 (patch)
tree4e7a77737c9aeb9849c996e86ef44589a072ee85 /lib/Monitoring/Plugin/Getopt.pm
parentc1046bab2e6681f5e4714178d6cc1cd16f067382 (diff)
downloadmonitoring-plugin-perl-40d5fbe.tar.gz
Change arg() param type detect to key exists check
Use the parameter label definitions from commit c1046ba to simplify the block of code that checks whether the first argument passed to arg() is one of the known param keys, rather than using a regular expression with alternating expression. This is more compact, may be marginally faster, and will make adding new parameters to this method more straightforward in future, avoiding the situation corrected in commit 4aa2aee.
Diffstat (limited to 'lib/Monitoring/Plugin/Getopt.pm')
-rw-r--r--lib/Monitoring/Plugin/Getopt.pm2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/Monitoring/Plugin/Getopt.pm b/lib/Monitoring/Plugin/Getopt.pm
index ca1cb61..feee002 100644
--- a/lib/Monitoring/Plugin/Getopt.pm
+++ b/lib/Monitoring/Plugin/Getopt.pm
@@ -392,7 +392,7 @@ sub arg
392 ); 392 );
393 393
394 # Named args 394 # Named args
395 if ($_[0] =~ m/^(spec|help|required|default|label)$/ && scalar(@_) % 2 == 0) { 395 if (exists $params{$_[0]} && scalar(@_) % 2 == 0) {
396 %args = validate( @_, { %params }); 396 %args = validate( @_, { %params });
397 } 397 }
398 398