use strict; use warnings; use PhoneList; my $mw = MainWindow->new; $mw->title("A phone List"); my $phoneNumbers = [ { number => '123-4321', enable => 'ACTIvE', description => 'Bob', }, { number => '321-1234', enable => '', description => 'Not Bob', }, ]; PhoneList::setup($mw, -numbers => $phoneNumbers;); MainLoop; ### A Different file package PhoneList; sub setup { my $parent = shift; my %args = @_; my $top = $parent->Frame()->pack( -fill => 'both', -expand => 'x', -ipadx => 5, -ipady => 5, ); my $list = $parent->Frame()->pack( -fill => 'both', -expand => 'both', -ipadx => 5, -ipady => 5, -anchor => 'n', ); $top->Label( -text => 'Enter some phone numbers.', )->pack( -side => 'top', ); $top->Label( -text => 'Check numbers to activate them.', )->pack( -side => 'top', ); $list->Label( -text => 'Enabled', )->grid( -column => 0, -row => 0, ); $list->Label( -text => 'Phone number', )->grid( -column => 1, -row => 0, ); $list->Label( -text => 'Description', )->grid( -column => 2, -row => 0, ); for ( 1..5 ) { $list->Checkbutton( -textvariable => \$args{-numbers}->[$_]{enable}, -offvalue => '', -onvalue => 'ACTIVE', )->grid( -column => 0, -row => $_, ); $list->Entry( -textvariable => \$args{-numbers}->[$_]{number} )->grid( -column => 1, -row => $_, ); $list->Entry( -textvariable => \$args{-numbers}->[$_]{description} )->grid( -column => 2, -row => $_, ); } } 1;