use Tk; my $var = foo(); print "profil:" . $$var; #print "profil:" . $var; sub foo(){ my $text = "Welches Profil soll bearbeitet werden?"; my $mw = tkinit(-title=> 'Profil'); my $frame1 = $mw -> Frame() -> pack(); $frame1->Label( -text => $text)->pack( -side => 'left' ); my $campus_frame = $mw->Frame()->pack(); my $campus_but = $campus_frame -> Button(-text=>"HAW_Campus", -command => sub {$mw->destroy(); my $var = "A"; return \$var}) -> pack(); #bzw. ohne \ $mw->focusForce(); $campus_but->focus(); MainLoop(); }