From 40d5fbea30c310004233ef4cd3e570c351c54233 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 16 Dec 2017 13:08:44 +1300 Subject: 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. --- lib/Monitoring/Plugin/Getopt.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') 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 ); # Named args - if ($_[0] =~ m/^(spec|help|required|default|label)$/ && scalar(@_) % 2 == 0) { + if (exists $params{$_[0]} && scalar(@_) % 2 == 0) { %args = validate( @_, { %params }); } -- cgit v1.2.3-74-g34f1