diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-12-16 13:08:44 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-12-16 13:08:44 +1300 |
commit | 40d5fbea30c310004233ef4cd3e570c351c54233 (patch) | |
tree | 4e7a77737c9aeb9849c996e86ef44589a072ee85 /lib/Monitoring/Plugin | |
parent | c1046bab2e6681f5e4714178d6cc1cd16f067382 (diff) | |
download | monitoring-plugin-perl-40d5fbea30c310004233ef4cd3e570c351c54233.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')
-rw-r--r-- | lib/Monitoring/Plugin/Getopt.pm | 2 |
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 | ||