Gossamer Forum
Home : General : Perl Programming :

Can someone tell me what this oneliner does ?

Quote Reply
Can someone tell me what this oneliner does ?
 
# We are processing the form.
if ((keys %in != 0) && (!$in{'product'})) {
&process_form;
}
Quote Reply
Re: Can someone tell me what this oneliner does ? In reply to
If the hash %in has something/anything in it, and the value associated with the product line in the %in hash exists, then run subroutine process_form...

Unless I misread it. :-)

------------------
Charles Capps
solareclipse.net/

[This message has been edited by Charles Capps (edited April 16, 1999).]
Quote Reply
Re: Can someone tell me what this oneliner does ? In reply to
Thanks!
Quote Reply
Re: Can someone tell me what this oneliner does ? In reply to
Ah, right. :-)
Quote Reply
Re: Can someone tell me what this oneliner does ? In reply to
For some reason, something in the back of my head keeps telling me that the code should be written as:

Code:
if ((keys %in) && (!$in{'product'})) {
&process_form;
}

I think the "!=0" part isn't really needed but it doesn't hurt. It could also be written as (someone correct me if I am wrong):

Code:
((keys %in) and (!$in{'product'}) and &process_form);
Quote Reply
Re: Can someone tell me what this oneliner does ? In reply to
Charles,

I think you are correct on the first part, but the "(!$in{'product'})" is checking to see if the product does not exist (note the ! before the $). So if the hash %in is not empty but there is no product, then process the form.