#!/usr/bin/perl -w use strict; use Tk; $| = 1; my $mw = MainWindow->new; my $text = $mw->Text->pack; my $bt = $mw->Button(-text => 'insert', -command => sub {&test_insert})->pack; MainLoop; sub test_insert{ for (1..3){ $text->insert('end', "$_\n"); } }