in reply to Execute a sub in the background

Can you give a bigger picture of what you are you trying to achieve? You can use threads, for example, or maybe GUI would be better for your application than command line interface.
Update: Other options include Coro, fork any many more.

Replies are listed 'Best First'.
Re^2: Execute a sub in the background
by egzoti4en (Initiate) on Feb 01, 2012 at 13:28 UTC

    I tried using threads but they don't execute in the background or i simply am not using them correct.

    for bigger picture you can see the code uploaded on my github account https://github.com/egzoti4en/MPG123FrontEnd.

    I'm trying to count the time that the song has lasted and to draw a status line of it. This what i want to do in this sub and that is why i need a sleep activity to make it sleep and then draw using Curses.(the sub is called status_line()

    I have alredy done almost everything so GUI is not an option for me now

      I tried using threads but they don't execute in the background or i simply am not using them correct.

      You do have to do a little more than put use threads; at the top of your code.

      Which is all you've done in the code you posted the link to. (It is preferred that you post your code here, not some other place on the net.)

      Did you read the POD for the threads module? Is there something you read but didn't understand that we could help you with?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

        Yes i'm not sure how to use threads.

        I wrote :

        my $thr = threads->create(\&status_line());$thr->join();

        The sub executes but i'm not able to get the key input.My program is waiting the thread to end. How can i make it not to wait for it.