Muskovitz has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks!

I want to make a Perl/Tk program that when a button gets clicked it'll execute a new thread. This is my very weird and junk code

#!/usr/bin/perl use strict; use warnings; use threads; use threads::shared; use Tk; my $mw=new MainWindow; $mw->title("Command Executor"); my $cmd=$mw->Entry(); $mw->Button(-text=>"Execute",-command=>\&execThread())->pack(); MainLoop; sub execThread{ my $command=$cmd->get(); my $thr=threads->create(sub{ system("$command"); })->join; }

Hope you could give me an advice.

Replies are listed 'Best First'.
Re: Perl/tk execute thread when button clicked
by choroba (Cardinal) on Aug 21, 2015 at 10:38 UTC
    Before asking a question, search whether it has already been asked: Re: Perl Tk and Threads
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Perl/tk execute thread when button clicked
by Anonymous Monk on Aug 22, 2015 at 01:03 UTC