in reply to Global variables and SimpleHTTP request handler

Hi Anonymous,

If you look at the source code of background, you'll see that it forks off a process to the background. You can't just use global variables to communicate between two forked processes. While it is in theory possible to communicate between the two (perlipc), I doubt that trying to implement this yourself is the easiest road to success.

In fact, I've worked with HTTP::Server::Simple a bit, and I can tell you this: even though it works great for simple stuff, if you find you want to do slightly more complex stuff and you start trying to bend the module to your will, you won't have fun. Instead, switching to a "real" web server ends up being much easier, even if it's just a simple PSGI app in plain Plack.

In general, it like sounds what you're trying to implement is a common thing, and so there are lots of possible solutions, many with existing modules and software. But if you could tell us more about the big picture of what you're trying to accomplish, that would help us in suggesting alternate solutions. What kind of requests does Scratch send (JSON? custom format?), what kind of commands do you want to execute, what does "process when able" mean, etc.

Regards,
-- Hauke D