Thanks for the help. Using $mw->destroy worked in exiting the MainLoop. However, I have a different issue now. Somehow, after I select my items and exit the menu, all the items listed get added regardless if I check them or not. Here's the code I'm using:
use strict; use warnings; use Tk; open(INFILE,"d1528235.txt") or die "could not open file for reading!\n +"; open(OUTFILE, '>forecast.txt') or die "Cannot open forecast.txt: $!"; while(<INFILE>){ if (m/^\s*$/) { next; } chomp $_; my @fields = split(/\ /,$_); my @output; foreach my $field(@fields){ if($field =~ /^\*?[ABMQRWY][A-Z0-9]{4}235 / ){ push @output,$field; } # print OUTFILE "$_\n"; } if (@output) { my $line = join('',@output); print "$line\n"; print OUTFILE "$line\n"; } } my $mw = MainWindow->new; $mw->geometry("300x500"); $mw->title("Unforecasted Jobs"); my $check1 = 'NOT CHECKED'; my $check2 = 'NOT CHECKED'; my $check3 = 'NOT CHECKED'; my $check4 = 'NOT CHECKED'; my $check5 = 'NOT CHECKED'; my $check6 = 'NOT CHECKED'; my $check7 = 'NOT CHECKED'; my $check8 = 'NOT CHECKED'; my $check_frame = $mw->Frame()->pack(-side => "top"); $check_frame->Label(-text=>"Jobs That Do Not Forecast")->pack(-side => + "top")->pack(); my $job = "18L"; my $chk1 = $check_frame->Checkbutton(-text => '18-Letters', -variable => \$check1, -onvalue => ' ADDED', -offvalue => 'NOT CHECKED')->pack +(), -command => print OUTFILE "$job\n +"; my $job2 = "07O"; my $chk2 = $check_frame->Checkbutton(-text => '07-Orders', -variable => \$check2, -onvalue => ' ADDED', -offvalue => 'NOT CHECKED')->pack +(), -command => print OUTFILE "$job2\ +n"; my $job3 = "36L"; my $chk3 = $check_frame->Checkbutton(-text => '36-Letters', -variable => \$check3, -onvalue => ' ADDED', -offvalue => 'NOT CHECKED')->pack +(); -command => print OUTFILE "$job3\ +n"; my $job4 = "38L"; my $chk4 = $check_frame->Checkbutton(-text => '38-Letters', -variable => \$check4, -onvalue => ' ADDED', -offvalue => 'NOT CHECKED')->pack +(), -command => print OUTFILE "$job4\ +n"; my $job5 = "11O"; my $chk5 = $check_frame->Checkbutton(-text => '11-Orders', -variable => \$check5, -onvalue => ' ADDED', -offvalue => 'NOT CHECKED')->pack +(), -command => print OUTFILE "$job5\ +n"; my $job6 = "99L"; my $chk6 = $check_frame->Checkbutton(-text => '99-Letters', -variable => \$check6, -onvalue => ' ADDED', -offvalue => 'NOT CHECKED')->pack +(); -command => print OUTFILE "$job6\ +n"; my $job7 = "21L"; my $chk7 = $check_frame->Checkbutton(-text => '21-Letters', -variable => \$check7, -onvalue => ' ADDED', -offvalue => 'NOT CHECKED')->pack +(), -command => print OUTFILE "$job7\ +n"; my $job8 = "23L"; my $chk8 = $check_frame->Checkbutton(-text => '23-Letters', -variable => \$check8, -onvalue => ' ADDED', -offvalue => 'NOT CHECKED')->pack +(), -command => print OUTFILE "$job8\ +n"; my $button_frame = $mw->Frame()->pack(-side => "bottom"); my $ok_button = $button_frame->Button(-text => 'OK', -command => \&check_sub)->pack( +-side => "left"); my $exit_button = $button_frame->Button(-text => 'Exit', -command => sub{$mw->destroy}) +->pack(-side => "right"); sub check_sub { my $check_msg = "Check #1: $check1\nCheck #2: $check2\nCheck #3: $ch +eck3\nCheck #4: $check4\nCheck #5: $check5\nCheck #6: $check6\nCheck +#7: $check7\nCheck #8: $check8\nCheck #9: $check9\nCheck #10: $check1 +0\nCheck #11: $check11\nCheck #12: $check12\nCheck #13: $check13\nChe +ck #14: $check14\n,Check #15: $check15\nCheck #16 $check16"; $mw->messageBox(-message => "Check Button Summary:\n$check_msg", -ty +pe => "ok"); } MainLoop; my $var =`crossref.pl`;
In reply to Re^3: Code after MainLoop; Tk
by PerlCowboy
in thread Code after MainLoop; Tk
by PerlCowboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |