in reply to Run another program without blocking or exiting (Perl/Tk).

  • On windows,  system 1, $cmd; will run the command asynchronously.
  • The Tk MainWindow method repeat calls the sub you bind to it at the regular intervals you specify:
    my $mw = MainWindow->new; .... $mw->repeat( 100, sub{ ## This sub is called every 1/10 th of a second } );

    I'd give a pointer to the documentation for repeat, but I have never found it. I saw it in a program once and just use it.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
  • Replies are listed 'Best First'.
    Re^2: Run another program without blocking or exiting (Perl/Tk).
    by ikegami (Patriarch) on Sep 02, 2005 at 08:24 UTC
      IPC::Open2 is a core module what will run a program in the background, and it's portable. (It uses system 1, in Windows, and fork+exec in unix.) I believe IPC::Run will do the same and has a better API, but it's not a core module.

        All true, but why are you telling me this?

      • The OP explicitly asked for a Windows solution.
      • IPC::Open2/Open3 are awkward and unreliable (on windows at least).
      • IPC::Run is a heavy, complicated behemoth.

        Any of the IPC::* modules is worth the effort of using, if you need the facilities they provide--ie. IPC between the spawned process and the spawning process. This requirement is not mentioned in the OP.

        Either way, wouldn't your post be better directed at OP (who may not know of these modules), rather than me (who does)?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
    Re^2: Run another program without blocking or exiting (Perl/Tk).
    by thundergnat (Deacon) on Sep 02, 2005 at 10:45 UTC

      For future reference, (Tk)repeat is documented under (Tk)after.