Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: perl/Tk Problem with referenced variable in Entry

by choroba (Cardinal)
on Nov 05, 2013 at 21:47 UTC ( [id://1061368]=note: print w/replies, xml ) Need Help??


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

Weird. You can simplify the code by removing the global $roomTl (which shortens roomSub), and you can also use a plain scalar to the same effect. I also added Devel::Peek to include some internal details.
#!/usr/bin/perl use warnings; use strict; use Tk; use Devel::Peek; my $val = 0.20; my $mw = 'MainWindow'->new; $mw->Button( -text => "\n Characteristics \n", -command => \&room, )->pack(-fill => "x"); $mw->Button( -text => "\n Calculate \n", -background => "red", -command => \&design, )->pack(-fill => "x"); MainLoop(); sub room { my $roomTl = $mw->Toplevel; $roomTl->Entry( -textvariable => \$val, )->pack(-fill => 'x'); } sub design { my $Uf = 13; my $Uw = $val * $Uf; # HERE print Dump($val), "\t Uf = $Uf \t val = ${\$val} \t Uw = $Uw \n"; }

Interestingly, to make the behaviour correct, just change the "# HERE" line to

my $Uw = "$val" * $Uf;
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1061368]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-26 02:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found