Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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?

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: (5)
As of 2014-12-27 08:02 GMT
Find Nodes?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?

    Results (176 votes), past polls