You need to be careful how you do this as Tk will block and you will not be able to access any other functionality of your Tk program until the called program exits. This may not be an issue unless the called program takes a long time to execute.

Also can I run a "EXE" program?

This leads me to believe you are doing this in a Windows environment. Check out Win32::Process for how to call an "EXE" as a subprocess (which will prevent blocking). The code below is a very simple example of what you are probably looking for.

use Tk; use Win32::Process; use Win32; use strict; my $mw = MainWindow->new(); my $npBtn = $mw->Button(-text => "Notepad", -command => [\&run_prog, "C:\\winnt\\system32\ +\notepad.exe"] )->pack(); my $cBtn = $mw->Button(-text => "Calc", -command => [\&run_prog, "C:\\winnt\\system32\\ +calc.exe"] )->pack(); MainLoop; sub run_prog() { my $prog = shift; Win32::Process::Create($po, $prog, "", 0, NORMAL_PRIORITY_CLASS, "." ) || die &error(); } sub error() { print Win32::FormatMessage( Win32::GetLastError() ); }
hope this helps,
davidj

In reply to Re: Running a new Perl program by davidj
in thread Running a new Perl program by Dirty Luigi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.