use Tk;
use strict;
use warnings;

# Die folgenden Pfade koennen von 
# Version zu Version wechseln
# Unix/Linux:
# my $path = '/usr/X11R6/include/X11/cursorfont.h';
# Windows:
my $path = 'C:\Perl\site\lib\Tk\X11\cursorfont.h';

my @cursors;

my $mw = MainWindow->new(-background => 'lightskyblue1');
$mw->geometry("200x200");
$mw -> title('Test für Listbox');

$mw->Button(-text => "Exit", 
            -command => sub { exit })
            ->pack(-side => "bottom", 
                   -fill => "x");

# Listbox mit Scrollbar einrichten                   
my $lb = $mw->Scrolled('Listbox', -scrollbars => 'oe',
                                  -height     => 5,
                                  -selectmode => 'single');
$lb->pack(-side => 'left', -fill => 'both');

## Datei einlesen,Cursornamen in der Listbox speichern
open (FH, "<", $path) || die "Oops: $!\n";
while (<FH>) 
  { push(@cursors, $1) if (/\#define XC_(\w+) /); }
close(FH);
$lb->insert('end', sort @cursors);

# Cursor beim Anklicken der Zeile aendern
$lb->bind('<Button-1>', 
     sub { $mw->configure(-cursor => $lb->get($lb->curselection)); });

MainLoop;