#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::MiniCalendar; my $date_sel = dates(); print $date_sel; # MainLoop; # bad placement sub dates{ my $out_date; my $top = MainWindow->new; my $frm1 = $top->Frame->pack; # Frame to place MiniCalendar in my $minical = $frm1->MiniCalendar->pack; my $frm2 = $top->Frame->pack; # Frame for Ok Button my $b_ok = $frm2->Button(-text => "Ok", -command => sub { my ($year, $month, $day) = $minical->date; $out_date = "$day-$month-$year"; # exit; $top->destroy; }, )->pack; MainLoop; return $out_date; }