On 3/28/11 Mon  Mar 28, 2011  12:44 PM, "Chris Stinemetz"
<chrisstinem...@gmail.com> scribbled:

> I would like to make an adjustment to this ternary operator.
> Instead of returning 0 if length( $dist ) is not > 1. I would like to
> return the last $dist value incremented by 0.1 mile so there is no gap
> of more than 0.1 miles.
> 
> $dist = sprintf "%.1f",
> ( length( $dist ) > 1 ) ? $dist/6.6/8/2*10/10 : 0 ;

Save the value of $dist in another variable, e.g. $prev_dist. Make sure that
the scope of the variable is outside the loop so that the value of
$prev_dist will persist from one iteration of the loop to the next.

Substitute the expression ($prev_dist + 0.1) for the 0 in the above
expression.

(Please post your queries to just the list and do not email individuals.
Thanks.)



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to