Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Nicer If...

by runrig (Abbot)
on Jul 12, 2001 at 23:12 UTC ( #96149=note: print w/replies, xml ) Need Help??


in reply to Nicer If...

One idea:
my @req_fields = qw( Shipping_address ... shipdayph ); my @filled = grep { $query->param($_) } @req_fields; failure if @req_fields && @filled
Update: I like suaveant's idea, though I think the conditional would be 'if $has == @ship_fields or $missing == @ship_fields'

Another update: Took suaveant's suggestion(s), thought I caught that first one :)

Ok, I get it now, duh..

Replies are listed 'Best First'.
Re: Re: Nicer If...
by suaveant (Parson) on Jul 12, 2001 at 23:16 UTC
    similar to mine, but probably a little better, if you did !$query->param($_) it would return a list of empty ones, tho, which would allow you to throw a useful error to the user, the check even still works, but I'd just check to see if $#filled == $#req_fields || !@filled, instead of hardcoding a number

                    - Ant

Re: Re: Nicer If...
by suaveant (Parson) on Jul 12, 2001 at 23:18 UTC
    actually, since he wants them all, if one of them is not equal to zero, then you fail... the check is right, just tricky

                    - Ant

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2022-11-30 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?