Phoenix.pm: Best PHP reference book?
scott at illogics.org
Mon May 5 10:50:41 CDT 2003
> PHP is basically a crippled version of Perl with some minor syntax
> differences. This is how I think of it and it's made it easy to
> transition from writing web applications in Perl to writing them in PHP.
> It's just another tool to do the same types of jobs for some people.
Yeah. Rewritting 6,000 lines of code is kind of throwing out the
baby with the bath water. I'd serious look at making a threading
server with HTTP::Server. Perl's threading (while I'm not fond
of the implementation) is safe - unless declared otherwise,
everything goes into thread-local-store, so it works like fork(),
but a lot more efficient, and using threads::shared, you need
only declare a variable (or queue or such object) to be :shared,
and all threads can see it and access it. You'd want the "worker
pool" example - one thread would listen for connections, and put
the work to be done on a queue, then you could have a handful of
threads taking things off of the queue, processing them, and
returning the output. The existing application would be a
worker thread and wouldn't change me. You'd want to tie STDOUT
for each process so that print(), printf(), write(), etc all
continued to work. The tied STDOUT would have to buffer up the
output and return it to the daemon thread to send as output, or
even pass it along in chunks in a queue for real-time-ish output.
In short, you're looking at adding about 100 lines of code,
rather than rewritting 6,000.
More information about the Phoenix-pm