#!/usr/local/bin/perl use strict; use warnings; use Tk; create_input_window('Test1','testsub1'); create_input_window('Test2','testsub2'); MainLoop; sub create_input_window { my $title = shift; # first line is the window title my $thissub = shift; # second line is the sub that is executed when the submit button is pressed my $mw = MainWindow->new(-title=>"$title"); my $mw_edit = $mw->Scrolled('Text',-relief => 'sunken', -borderwidth => 2, -scrollbars=>'osoe')->pack(-expand => '1', -fill => 'both'); my $subtoexecute = sub{testsub1($mw_edit->get('1.0', 'end'))}; # <-- wie kann man hier testsub1 durch die Variable $thissub ersetzen ? my $mw_submit_button = $mw->Button(-text => 'Submit',-background=>'gray',-command=> $subtoexecute )->pack(-side=>'left'); my $mw_close_button = $mw->Button(-text => 'Close',-background=>'gray',-command => sub{$mw->destroy})->pack(-side => 'top',-expand => '0',-fill => 'x'); $mw_edit->insert('end',"aA\nbB\ncC"); } sub testsub1 { my $contents=shift; my $linecount=0; foreach my $line (split(/\n/,$contents)) { $linecount++; print "$linecount: ".uc($line)."\n"; } } sub testsub2 { my $contents=shift; my $linecount=0; foreach my $line (split(/\n/,$contents)) { $linecount++; print "$linecount: ".lc($line)."\n"; } }