When you create a PerlTk callback that will take arguments, using the [] syntax, the Tk::callbacks documentation says:

the contents of the [] are evaluated by perl when the callback is created

Therefore, your code,

$mw->Button ( -command => [\&print_entries, $user_x->get(), $original_y], );
is roughly the equivalent of this:
my $command_sub; { my $x_at_time_of_sub_definition = $user_x->get(); my $y_at_time_of_sub_definition = $original_y; $command_sub = sub { print_entries( $x_at_time_of_sub_definition, $y_at_time_of_sub_definition, ); } } $mw->Button ( -command => $command_sub, );

Instead of telling PerlTk to create the callback, create it yourself with an anonymous sub. This should work for you:

-command => sub { print_entries( $user_x->get(), $user_y->get(), $original_x, $original_y, ); },


In reply to Re: Tk -textvariable doesn't change when Entry widget changes by Util
in thread Tk -textvariable doesn't change when Entry widget changes by Petras

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.