in reply to Re^2: Looping in the background of your main program
in thread Looping in the background of your main program

but still do not understand how to fork a process and use my variables from my main process there aswell

The point is, you can't (directly). At the time of forking, all program data (including variables with their current values) are being duplicated, but from that point onwards, updates to the two copies of the variables do happen independently.  It's for that reason that you'd then need IPC.

With threads and threads::shared, OTOH, you can tell Perl which variables you want to share across the different threads.  But threads may be problematic in other ways, for example in that code (which you've loaded before creating a new thread) needs to be thread-safe — which in particular external libraries (as often needed with XS modules) sometimes aren't.

  • Comment on Re^3: Looping in the background of your main program

Replies are listed 'Best First'.
Re^4: Looping in the background of your main program
by dk (Chaplain) on Jan 01, 2010 at 15:05 UTC

      True, and it's probably always good to post a reminder of forks in discussions about threads. However, it should be noted that the forks module explicitly doesn't work on Windows. Follow the link to forks and do a text search for Windows for an explanation. This is particularly important since the OP is using Windows.