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

Hey Monks,
I was wondering if it was possible to fork off a section of code, i.e make it run independent to the rest of the script, whilst still giving it access to the global variables the script has?

I need my script to sit waiting for connections using NetServer::Generic, whilst in the background waiting for messages, and pushing them to the appropriate client by calling a series of callbacks (subroutine references) stored in a global hash assorted with the username.

To be honest i'm not even sure if i'm going about this the right way, i think what i need to do is sort of outside the bounds of NetServer::Generic, but i'd really like to avoid rewriting my existing code without this module as i don't have the time.

Any help would be much appreciated

Neil Archibald
Games on Demand

Replies are listed 'Best First'.
Re: Fork accessing global variables?
by ysth (Canon) on Feb 20, 2004 at 05:59 UTC
    The variables you need to share can be tied with IPC::Shareable, which see.