Popcorn Dave has asked for the wisdom of the Perl Monks concerning the following question:
I've been beating my head against the wall with this for a couple of days now and still can't figure it out.
I'm writing a TK program that returns a scrollable list based on the user's search parameters and then displays the data in Tk Entry fields on the screen. All well and good, but since my data is set up as a HoAoH, I'm using a ternary expression in the Bind to determine what data I'm going to display.
Here's my code:
$results->bind('<ButtonRelease-1>'=> sub{ $list = $results->curselection; $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 thing I can't figure out is when my selection key is not "year" the routine works fine. However when it is year, I keep getting a "Tk::Error: Can't modify non-lvalue subroutine call".
I don't understand why this is popping up. I know the values of $data and $list are populated. $data is the year I'm searching on, and $list is the array index from the scrollable list. I've even tried placing static values in that part of the code rather than variables and I still get the same error. Data::Dumper shows that the data is actually in the structure, and the data I want to display, so I'm totally confused. Even more so since the same subroutine call works when my key is anything but "year".
If there is a problem with how I'm sending the data to the subroutine, I can't see it. The subroutine &show is simply taking the data it gets passed, and displaying it in the entry fields.
Any help to clear this up would be greatly appreciated!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help with binding event in Tk
by keszler (Priest) on Jul 23, 2004 at 06:16 UTC | |
by Popcorn Dave (Abbot) on Jul 24, 2004 at 18:43 UTC | |
by keszler (Priest) on Jul 25, 2004 at 07:19 UTC | |
|
Re: Need help with binding event in Tk
by runrig (Abbot) on Jul 23, 2004 at 06:09 UTC | |
by Popcorn Dave (Abbot) on Jul 24, 2004 at 18:39 UTC | |
by runrig (Abbot) on Jul 25, 2004 at 01:22 UTC | |
|
Re: Need help with binding event in Tk
by PodMaster (Abbot) on Jul 23, 2004 at 05:23 UTC |