in reply to Re: Need help with binding event in Tk
in thread Need help with binding event in Tk

I had assumed, and apparently a bit mistakenly, that the ternary could handle more than just variable assignments. I have changed it to an if-else and it's working now. I still can't understand why in the ternary wouldn't evaluate the true part of the expression but would the false.

As far as the indentation, the while loop actually does activate when the key is not "year". The indentation was merely so that I didn't have a line that extended out 100+ characters and would wrap when I printed the code to look at it on paper.

There is no emoticon for what I'm feeling now.
  • Comment on Re^2: Need help with binding event in Tk

Replies are listed 'Best First'.
Re^3: Need help with binding event in Tk
by keszler (Priest) on Jul 25, 2004 at 07:19 UTC
    The (or at least a) problem as I saw it is that as written:

    $key eq "year" ? &show($bros->{$data}->[$list]) : $index = 0; while($bros->{$ydx[$list]}->[$index]->{$key} !~ $data/i){ $index++; } $yr = $ydx[$list]; &show($bros->{$ydx[$list]}->[$index]);

    the indentation is hiding what's happening. When written:

    $key eq "year" ? &show($bros->{$data}->[$list]) : $index = 0; while($bros->{$ydx[$list]}->[$index]->{$key} !~ /$data/i){ $index++; } $yr = $ydx[$list]; &show($bros->{$ydx[$list]}->[$index]);

    it is much more obvious that the while loop and two following statements are executed no matter what value $key holds.