Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple : variable sanity check.

Status
Not open for further replies.

lych

IS-IT--Management
Nov 25, 2003
8
AU
I have such a stupid simple question.

I have a variable $key.

I want to test if it has a numeric value between 1 and $buildcount.

I looked at populating an array;

@range = (1 .. $buildcounter);

And using grep to exact match $key within @range. But I cannot get it to exact match. Can anyone point me in the right direction to a solution?

thanks
 
one possibility:

Code:
if ($key > 1 && $key < $buildcount) {
   do something
}
else {
   do something else
}

if you mean equal to or greater than 1 and $buildcount

Code:
if ($key >= 1 && $key <= $buildcount) {
   do something
}
else {
   do something else
}
 
Jeebus. I must be having one of those days. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top