in reply to perl/Tk Problem with referenced variable in Entry

Looks like when the toplevel gets destroyed, the window{xAf} gets grinitialigzed to 0 under some circumstances ... probably a bug since as choroba shows stringification gives the correct value

This might be a bug worth reporting to the maintainer, rt://Tk

 

However, creating a Dialog instead of a toplevel naturally works as intended

sub roomSub { if (! Exists ($roomTl)) { warn "textvariable"; #~ $roomTl = $mw->Toplevel(); $roomTl = $mw->Dialog(); $roomTl->Entry( -textvariable => \$window{xAf}, )->pack(-fill => 'x'); } $roomTl->Show(); }

Also, I won't bug you about tk scoping function argument passing

Replies are listed 'Best First'.
Re^2: perl/Tk Problem with referenced variable in Entry (bug)
by contact@solamen.fr (Novice) on Nov 06, 2013 at 13:06 UTC
    Thanks for your answer and for bugging me :) with argument passing and closures: I had no idea it was a lack of robustness in perl (or just Tk?). I have literally hundreds of variables handled in dozens of hashes so I feel kind of reluctant to rewrite my subroutines so they take arguments and return variables. For the moment I turned towards choroba patch and interpolate as much as possible. I also forwarded the post to rt.Tk as you suggested. Best
      rt.cpan 90077
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ