I have an old and very large Perl Tk GUI application that I'm refactoring to Tkx. I want to split the interface into several packages so I can build up the application UI in a modular manner. Also, I want to keep the View separate from the Model, using a Controller to provide an interface between the two.
It seems to me that the only way to design this is with two huge global variables, one holding the model ($MODEL), and the other holding references to the widgets ($UI) that are spread across many packages. Then, the Controller interfaces the two using a series of commands like the following:
$UI->{'entry_widget'}->configure(-variable=>\$MODEL->{'entry_value'});
$UI->{'button_widget'}->configure(-command=>sub {$MODEL->{'entry_value'} = "New Value"} );
My question is: Is there a better way to design the application which avoids having to use these two big globals ($UI and $MODEL)? Any suggestions would be very welcome.