In the below example you are saying if $gimp equals "gimp" or if "gimps". The First part of the if is actually testing values while the second part of the if statement is always true... therefore always printing working. you could try
if ($gimp =~ /gimp/) { print "working"; } The above example matches if the word gimp is found anywhere in $gimp. There are 10 types of people... Those who understand binary and those who dont.... |---------+----------------------------> | | "Josh Corbalis" | | | <[EMAIL PROTECTED]| | | k12.in.us> | | | | | | 07/16/2003 12:33 | | | PM | | | | |---------+----------------------------> >------------------------------------------------------------------------------------------------------------------------------| | | | To: [EMAIL PROTECTED] | | cc: | | Subject: needing help with the or, || operators | >------------------------------------------------------------------------------------------------------------------------------| I've been coding some basic programs learning perl and I'm having some problems with the or operators. Here are a couple coding samples if anyone knows what I'm doing wrong with this please tell me. #!/usr/bin/perl $gimp=<STDIN>; chomp ($gimp); if ($gimp eq "gimp" || "gimps") { print "working"; } print "\n"; With this one I'm trying to just print out the string "working" if the user enters either "gimp" or "gimps". No matter what is entered here it still prints out "working" though. I've also replaced the "||" with "or" in that last example but it does the same thing. I can fix the program with either this bit of code: #!/usr/bin/perl $gimp=<STDIN>; chomp ($gimp); if ($gimp eq "gimp") { print "working"; } elsif ($gimp eq "gimps) { print "working"; } print "\n"; or this one: #!/usr/bin/perl $gimp=<STDIN>; chomp ($gimp); if ($gimp eq "gimp" || $gimp eq "gimps") { print "working"; } print "\n"; Is this a problem with the or operators or do I just always have to specify $gimp eq "string1" || $gimp eq "string2"? I would think you would be able to just leave off the second $gimp eq. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ------------------------------------------------------------------------ The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]