Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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

Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (15)
As of 2016-10-24 13:30 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (305 votes). Check out past polls.