--------------------------- mail program -------------- myquery ('3933'); #this is parent process $| = 1; # turn off buffering $newpid = fork(); if ( not defined $newpid ){ # if return value of fork() is undef, something went wrong die "fork didn't work: $!\n"; } elsif ( $newpid == 0 ){ # This is what the child process does print "inside child---------\n"; myquery ('3934'); exit( 0 ); } myquery ('3932'); ----------------one subroutine--------------------- sub myquery { my ($target_member_id) = @_; my ($query) = "select username from member where id=$target_member_id"; my ($sth) = $mypackage::dbh->prepare ($query); $sth-> execute; my ($row) = $sth->fetchrow_array; if($row) { print "row: $row\n"; } else { print "empty\n"; } $sth->finish; } ---------------the perl module to establish the db connection ------ package mypackage; use DBI; $dbh = DBI->connect("$DB_SERVER:$DB_NAME;$DB_HOST",$DB_USERNAME,$DB_PASSWORD) || die "Content-type: text/html\n\nCan't connect to $dbname: $DBI::errstr\n"; ... ...