The code

if ( $variable > -10 and $variable < 10 ) {
        # do something
}

Will not catch -10 itself or 10, so this is really like saying from -9
to 9.

If you want to include -10 and 10, use this

if ( $variable >= -10 and $variable <= 10 ) {
        # do something
}

But yeah, it looks like this code always executes the statement anyways.

====================
Brian Arnold
[EMAIL PROTECTED]

-----Original Message-----
From: Heely, Paul [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, October 18, 2001 9:40 AM
To: 'Mark Martin'; [EMAIL PROTECTED]
Subject: RE: "BETWEEN" Comparison Operator


Hi,

The following if checks for variable between -10 and 10.
if ( $variable > -10 and $variable < 10 ) {
        # do something
}

The example you gave looks like it always executes though, so maybe I'm
missing something.

--Paul




> -----Original Message-----
> From: Mark Martin [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, October 18, 2001 10:31 AM
> To: [EMAIL PROTECTED]
> Subject: "BETWEEN" Comparison Operator
> 
> 
> Hi,
> very simple question here I think. Trying to get an IF to 
> test whether a
> numeric variable is in a certain range & if it is then 
> execute an action :
> 
> if ($variable <-10) {
> 
>                       $sth1->execute($variable) or die "Can't 
> execute SQL statement:
> $DBI::errstr\n";
> 
> }elsif ($variable >10) {
> 
>                       $sth1->execute($variable) or die "Can't 
> execute SQL statement:
> $DBI::errstr\n";
> 
> }else {       
>       
>                       $sth1->execute($variable) or die "Can't 
> execute SQL statement:
> $DBI::errstr\n";
> 
> }             
> 
> I can only seem to do this with 2 conditional statements(IF & 
> ELSIF) and
> the action repeated. What I want is a "Between" operator for 
> the range -10
> to 10.
> 
> Any ideas,
> Mark
> _____________________________________________
> 
> Mark Martin
> Computer Centre
> National University of Ireland Maynooth
> 
> Tel: (01)708 4716/3830
> Fax: (01)628 6249
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to