Here's a little info that will help you understand Perl/Tk programs:
Perl/Tk applications are event driven, which means that the program waits for "events" (keyboard, mouse, etc) and then executes accordingly. Event driven programs have a loop somewhere in them that catches and processes these "events". This is what
MainLoop in Tk is. It is simply a while loop that catches and processes events. Consequently, the code after
MainLoop never gets executed, unless it is
1) part of a sub that is called before
MainLoop executes or
2) part of a callback attached to a Tk widget.
This is why
print @a; never prints. To get it to print, put it in a sub that is part of a callback. Something like:
$mw->Button(-text => "print", -command=> sub {print @a })->pack;
or
$mw->Button(-text => "print", -command => \&print_it);
then somewhere below
MainLoop
sub print_it() {
print @a;
}
For a better explanation of Perl/Tk programming I would suggest that you get the book
Mastering Perl/Tk.
Hope this helps,
davidj
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.