# Here's one way:

        my $speed_cost_code = '';
        if    ($avg_speed >= 0  && $avg_speed <=  5) { $speed_cost_code =
"A"; }
        elsif ($avg_speed >  5  && $avg_speed <= 15) { $speed_cost_code =
"B"; }
        elsif ($avg_speed > 15  && $avg_speed <= 25) { $speed_cost_code =
"C"; }

# But I don't like repeating the '5' and '15' - just begging for a typo.

# Maybe:

        my $speed_cost_code ;
        if    ($avg_speed <   0) { $speed_cost_code = ''; }
        elsif ($avg_speed <=  5) { $speed_cost_code = "A"; }
        elsif ($avg_speed <= 15) { $speed_cost_code = "B"; }
        elsif ($avg_speed <= 25) { $speed_cost_code = "C"; }
        else                     { $speed_cost_code = ''; }

# But I don't like doing the $speed_cost_code = ''; twice.

# Or:

        my $speed_cost_code ;
        if    ($avg_speed <   0 || $avg_speed > 25) { $speed_cost_code = '';
}
        elsif ($avg_speed <=  5)                    { $speed_cost_code =
"A"; }
        elsif ($avg_speed <= 15)                    { $speed_cost_code =
"B"; }
        elsif ($avg_speed <= 25)                    { $speed_cost_code =
"C"; }

# But the initial compound condition could be confusing.

# Oh well, TMTOWTDI...


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 15 May, 2002 05:30
To: [EMAIL PROTECTED]
Subject: If...


hello everybody,
I have a little problem with if... it seems to be very simple but I just
cannot 
find a working solution
here the code - there must be sth wrong within the term. does anybody know a

solution?
        
        my $speed_cost_code = '';
        my $avg_speed = $link_attr_entry->access("Avg. Speed");
                
                if    (   0 <= $avg_speed <=   5 )   { $speed_cost_code =
"A";  
} 
                elsif (   5 <  $avg_speed <=  15 )   { $speed_cost_code =
"B";  
}
                elsif (  15 <  $avg_speed <=  25 )   { $speed_cost_code =
"C";  
}


thanks in advance

Stefan

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

Reply via email to