my $mw = MainWindow->new; $mw->geometry("500x250"); /*Other stuff*/ $mw->Button(-text=>'OK',-background=>'blue',-command=>\&ok_but)->pack(-side=>'top',-pady=>2); MainLoop; sub ok_but { $receiptno=40; /*Other stuff*/ $sw->Button(-text=>'Deposit work receipt',-background=>'blue',-command=>\&deposit)->pack(-side=>'top',-pady=>2); sub deposit{ my $dw = MainWindow->w; $dw->geometry("500x700"); /* Entry boxes and lists where user enters/selects data for receipt generation */ $dw->Button(-text=>'Print receipt',-background=>'blue',- command=>\&deposit_fwrite_print)->pack(-side=>'top',-pady=>2); } sub deposit_fwrite_print{ /* Write data to text file and print recipt receipt using Win32::Printer::Direct; */ $receiptno=$receiptno +1; } } End of subroutine ok_but