Sponsoring The Perl Toolchain Summit 2025: Help make this important event another success Learn more

#!/usr/local/bin/perl -w
use Tk;
use Tk::Xrm;
use Tk::widgets qw(DirTree Button);
# This does not work properly yet
use strict qw(subs);
sub top
{
my $name = shift;
my $top = MainWindow->new();
$top->Button('-text'=>"Quit",'-command'=>['destroy',$top])->pack;
$top->Button('-textvariable'=>\$name,
'-command'=> [ sub { my $name = shift; print "$name\n"},$name])->pack;
$top->DirTree()->pack;
$top->title($name);
}
&top("One");
&top("Two");
MainLoop;