perl TK combination/ I cannot find any example [migrated]

I'm searching for any moderately short example that I can download which would combine Perl/GTK or any other graphics environment with buttons displayed after excution.


Solution 1:

#!/usr/bin/perl
use warnings;
use strict;

use Tk qw{ MainLoop };

my $mw = 'MainWindow'->new;
my $b_show;
$b_show = $mw->Button(-text    => 'Show',
                      -command => sub {
                          $b_show->configure(-command => undef);
                          $mw->Button(-text    => 'Quit',
                                      -command => sub { exit })->pack;
                      })->pack;
MainLoop();