Hi all,

I have some subroutines that return information. Since the each
subroutine takes a snapshot of data on networked servers that should
be compared, I want the subroutines to execute in the shortest time
possible - I'd like to get all the subroutines running at the same
time. I thought of using fork() but I have not seen any code that
shows me how a forked process returns data to the parent process. And
from what I've read in the Camel book, "everything else (except file
descriptors) is copied" to the child process when fork()ed, so passing
the reference ta a hash will not work. But what if the child was
generating hashes and wanted to pass it to the parent?

Q: How can I pass info (hashes / strings) from a child process to a
parent when the child is done processing?

Currently my code looks like:

BEGIN
#!/usr/bin/perl -w

use strict;

my ($val, $val2, %opc01, %opr01, %opd01);

sub q_db;
sub build_hash;

build_hash("db1", \%opc01); # This should be forked or something
build_hash("db2", \%opr01); # This should be forked or something
build_hash("db3", \%opd01); # This should be forked or something

sub build_hash {
        for( q_db("$_[0]") ) {
            # extract fields with regex
                $_[1]{"$val"} = ("$val2");
        }
}

sub q_db {
 # Execute "db" query on another host
}
END

TIA


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This e-mail and its contents are subject to the Telkom SA Limited
e-mail legal notice available at
http://www.telkom.co.za/TelkomEMailLegalNotice.PDF
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to