Hi all. I'm stumped. I've been toying with a small financial application using Perl/Tk and I've come across what I think is a scope problem, but it sure doesn't make sense to me.
I'm attempting to call a subroutine from a button and pass the value that is supposed to be set from a radiobutton. Like this:
-command => [\&Account_Setup, $acct]
$acct gets set with a radio button variable:
$f->Radiobutton(-text => "Investment",
-value => "investment",
-variable => \$acct)->pack(-side => 'top',
-anchor => 'w');
The subroutine contains a simple print statement for testing:
sub Account_Setup{
my ($acct_type) = shift;
print "Account Type: $acct_type\n";
}
The problem is, the button code above doesn't seem to be passing the value stored in $acct. However, this code on the button works:
-command => sub{ print "Account: $acct\n"; }
In addition, if I set the value of $acct right before passing it, the subroutine seems to work fine as well.
Is this some sort of scope problem or am I missing something really obvious? Any suggestions would be greatly appreciated.
TIA.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.