in reply to OO Perl and Tk
You don't necessarily have to switch to OO programming. Maybe you can first organize your code better, but still use the procedural style? As for the global variables: the only global variable representing a widget you really need is $mw. All other widgets may be expressed as subwidgets. See the Tk::mega manual about Subwidget and Advertise. If you have non-GUI data, then you may consider to move just these parts into modules. Consider to create megawidgets if possible (the Tk::mega manual also helps here). Limit the scopes of variables as much as possible by using functions or just blocks, e.g.:
# ... code before { my $f = $top->Frame->pack; # frame needed only for layouting pur +poses $f->Label(...)->pack(...); $f->Label(...)->pack(...); ... } # ... not interested in $f anymore ...
|
|---|