in reply to How best to validate the keys of hashref arguments?
if you know what keys are allowed you can check for ones that are not allowed
my %allowed = map ( $_ => 1 } qw/ name user host command/; for my $cmd (@commands) { my $badkeys=''; for my $key (keys %$cmd) { unless ($allowed {$key) {$badkeys.=' '.$k} } if ($badkeys) { print 'skipping due to badkeys found:'.$badkeys."\n"; next; } if ($state->{status} eq 'success') { ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How best to validate the keys of hashref arguments?
by johngg (Canon) on Mar 16, 2017 at 00:08 UTC | |
by cbeckley (Curate) on Mar 16, 2017 at 14:46 UTC |