#!/usr/bin/perl use warnings; use strict; use Tk; my $data = 'whatever'; # do whatever here to print to STDOUT or xterm # or # to display the Tk if (fork == 0) { my $top = new MainWindow; $top->geometry('200x200+100+100'); $top->Label( -text=> $data )->pack(); $top->Button( -text => 'Exit', -command => sub { exit })->pack; MainLoop; CORE::exit(); } # always do your forks first, before creating Tk in the main script # my $mw = new MainWindow; # MainLoop; # not needed in this example # non Tk script t can continue here for (1.. 3){ print "$_\n"; sleep 1; } exit; #If you need start a new process from one of the child processes, then #you have to establish some kind of IPC (e.g. pipes) between the child #and parent. #I the launched task running another Perl/Tk module or function or a #complete new program? In the latter case, you should just use fork and #exit/system and do not forget to use CORE::exit instead of exit in the #child process (according to the FAQ). Perl/Tk forks are somewhat more #difficult. You have to make sure that you fork off the process which #does not have a created a MainWindow itself. This will work fine: