in reply to Re^3: check parameters
in thread check parameters

This should fail and doesn't:
use strict; use warnings; use Pod::Usage; my $format = { abc => 1, bar => 1, fii => 1, wee => 1, }; my $opts; $opts->{params} = ["a", "fa"]; my $str = "(".join('|', @{$opts->{params}}).")"; if (!grep { /^$str/i } keys %$format) { pod2usage( -verbose => 0, -output => \*STDERR, -msg => "$0 bad parameter difinition used [" . join(", ", so +rt {$a cmp $b} @{$opts->{params}}) . "].\n" . "Possible parameters are: " . join(", ", sort {$a cmp $b} keys %$format) . "\n"); } print "1\n";

Replies are listed 'Best First'.
Re^5: check parameters
by hdb (Monsignor) on Apr 08, 2013 at 14:50 UTC

    You want it to fail if one of them fails, correct? Try this:

    if ( scalar( grep { /^$pattern/i } keys %$format ) < scalar( keys %$fo +rmat ) ) { ...
Re^5: check parameters
by hdb (Monsignor) on Apr 08, 2013 at 16:16 UTC

    Or this? (Observe the position of the exclamation mark.)

    if ( grep { !/^$str/i } keys %$format)