When you create your button with:
It uses the value of $acct that exists at the time the button is created. If that value of $acct is then changed later on, the button isn't going to pick up on this.-command => [\&Account_Setup, $acct]
Instead of passing in $acct (which gives you the contents of the $acct variable), you can instead pass in a reference to the variable:
Now, when your button is pressed, it gets a reference to $acct, which you can dereference to get the current value of $acct, like this:-command => [\&Account_Setup, \$acct]
This should hopefully solve your problem.sub Account_Setup { my $acct_type = ${shift()}; print "Account Type: $acct_type\n"; }
Trap for the unwary:It's important to use ${shift()} rather than ${shift}. The first is calling perl's built-in shift function and then de-referencing the result into a scalar. The second is the varaible named $shift.
Cheers,
Paul
In reply to Re: Scope with Perl/Tk
by pjf
in thread Scope with Perl/Tk
by berniep
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |