Hi Vance, This sounds silly, but Why do you need to know? If your operation is as simple as trying to decide whether or not to insert a comma or other separator, you can do that with the JOIN command without checking the individual values.
$result = join(',' ($var1, $var2)); $result will be: "" or "$var1" or "$var2" or "$var1,$var2" You also have the inline if: $result = ($var1 ne "" ? ($var2 ne "" ? "Both" : "Var1Only") : ($var2 ne "" ? " Var2Only " : "Neither"); $result will be one of: "Both", "Var1Only", "Var2Only", "Neither" David Luke, Application Developer IV Isocorp, Inc. DMS Enterprise Information Technology Services 100 Rhyne Building 2740 Centerview Drive Tallahassee, Florida 32301 (850) 216-3746 -----Original Message----- From: Vance M. Allen [mailto:[EMAIL PROTECTED] Sent: Sunday, September 25, 2005 2:42 AM To: beginners-cgi@perl.org Subject: "if" Question Greetings, I have several places in my code where I need to check if two string variables are empty, if one is empty and the other is not, and if they're both populated. Is there any simpler way to write the code than this?: if($var1 ne "" and $var2 ne "") { # Both are populated... # ... } elsif($var1 ne "" or $var2 ne "") { # One or the other is populated... # ... } else { # Neither are populated... # ... } The reason I ask is that some of the code gets to be fairly long when I'm checking things this way, and so I just wondered if there was any shorthand/shortcut way to have Perl check if two strings are empty in one expression...regular expressions, maybe? I appreciate any help, suggestions, or answer you can provide. Thanks, Vance -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>