sub update_sample_data { my ($text_display, $text_data, $start_data, $end_data, $sheet, $nr, @headlines) = @_; my $display_text = $text_data->get("0.0", "end"); $display_text =~ s/$start_data([^$end_data]+?)$end_data/$sheet->Range(&get_a1($nr, &array_index($1, @headlines)))->{Value}/sgei; $text_display->delete("0.0", "end"); $text_display->insert("end", $display_text); } my $btn_show = $combi_window->Button( -text => $start_data.' abc '.$end_data, -font => ['Tahoma', 8, 'bold'], -width => 7 ); $btn_show->configure ( -command => sub { &update_sample_data($text_display, $text_data, $start_data, $end_data, $sheet, $nr, @headlines); } );