Fellow monks,

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!

There is no emoticon for what I'm feeling now.

In reply to Need help with binding event in Tk by Popcorn Dave

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.