fork():

I'm trying to put a perl wrapper around some clunky java code to make it play nicer. The best arrangement I have come up with is to use:

open(JVM, "java_app.sh |");

I suppose I could use system() as well, but if I read correctly the STDOUT from the java application would become the STDOUT of my perl application. I'm pretty sure I don't want to do that. So for now I'm going to capture it and see if there is anything interesting in it.

BTW: Building this application by creating the test modules before the code has been interesting. I'm not 100% test first then write, but I'm getting better. Is it typical/reasonable to consider one test script for each function?

Currently I have a mostly procedural module approach with a big fat
while(1) {
        my $pid = fork;
        if ( $pid ) {
                # PARENT
                ...
        } else {
                # CHILD
                ...
                open(JVM, "java_app.sh |");
                ...
                exit 0;
        }
}

kind of code model to get the work done.

I'm curios if this could be and should be dumped into an Object.
Any reason not to fork() inside an Object?
I'm not sure it makes sense, since each Object would 'exit 0;' on itself. Kind of a bizarre approach. I'm a little hesitant to fork() too much stuff where I'm at. It's a Sun box and there are some very real problems with forking when compiled under gcc. Somewhere there's a bug but it took a better man than me to find the report on the internet.


Logging:

I am using a package Log::Dispatch to do my logging.
Is there any penalty to loading the same modules for Log::Dispatch into multiple Packages (Main plus all my custom package/modules)? IIRC this should share the memory but allow each package space to see the Log::Dispatch methods with no penalty memory or speed.

True?

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to