Gossamer Forum
Home : Products : DBMan : Customization :

Greater than - Less than "if" statement help

Quote Reply
Greater than - Less than "if" statement help
I want to do a range with an "if" statement but need some help... this is what I would like to do ....

elsif ($per_admin || $per_mem && $diff >7 < 30 ) {
print qq|print something|;
}

greater than 7 and less than 30 how would I put together the "if" syntaz for this?

TIA,

Donm
Quote Reply
Re: [donm] Greater than - Less than "if" statement help In reply to
Code:
if ((($per_admin) || ($per_mem)) && (($dif > 7) || ($dif < 30))) {
print qq| something |;
}


if ((($per_admin) || ($per_mem)) && (($dif > 7) || ($dif < 30))) {
print qq| something |;
}
Quote Reply
Re: [Watts] Greater than - Less than "if" statement help In reply to
Ok, it doesn't seem to be working like I want it to... here is the code that I am using:

if ((($per_admin) || ($per_mem)) && (($diff > 7) || ($diff < 30))) {
print qq| print something |;
}
elsif ($per_admin || $per_mem && $diff > 30) {
print qq| print something else |;
}
elsif ((($per_admin) || ($per_mem)) && (($diff > 0) || ($diff <= 7))) {
print qq| print something else|;
}
else {
print qq| print something else |;
}


The first if is all that is printing no matter what...

It works if I put it like this:

if ($per_admin || $per_mem && $diff < 30) {
print qq| print something|;
}
elsif ($per_admin || $per_mem && $diff > 30) {
print qq| print something else |;
}
else {
print qq| print something else |;
}

But I want to print something if it's greater than 7 and less than 30 not just less than 30.

Not sure what I doing wrong?

Last edited by:

donm: Nov 25, 2003, 1:13 PM
Quote Reply
Re: [donm] Greater than - Less than "if" statement help In reply to
I figured it out... helps to have the book "Teach Yourself Perl in 24 Hours" LOL

Here's how it should have been:

if ($per_admin || $per_mem && $diff > 30) {
print qq| print something |;
}
elsif ($per_admin || $per_mem && $diff <= 30 && $diff > 7) {
print qq| print something else |;
}
elsif ($per_admin || $per_mem && $diff <= 7 && $diff > 0) {
print qq| print something else |;
}
else {
print qq| print something else |;
}

This works perfectly!! Wink

Maybe it will help someone else that is having the same problem.

Donm
Quote Reply
Re: [donm] Greater than - Less than "if" statement help In reply to
Great! Glad you got it working.

I was using "Perl for Dummies" (really!) and I would have never guessed it would work without all of the sets parenthesis.
Quote Reply
Re: [Watts] Greater than - Less than "if" statement help In reply to
Hey thanks for trying!!Smile