Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^4: check parameters

by ag4ve (Monk)
on Apr 08, 2013 at 14:42 UTC ( #1027525=note: print w/ replies, xml ) Need Help??


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";


Comment on Re^4: check parameters
Download Code
Re^5: check parameters
by hdb (Prior) 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 (Prior) on Apr 08, 2013 at 16:16 UTC

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

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1027525]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2014-11-26 13:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (171 votes), past polls