473,395 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

perl Fock & DBI problem

Hi, thank you for taking your previous time to read the following
problem that I face.

I'm trying to create multiple child process and TESTCODE 1 work fine,
however if I try to connect to MYSQL (TESTCODE 2) before calling the
subroutine "testmail2", I would never get the expected result. I would
appreciate if anyone would be so kind to help me solve the problem or
suggest an alternative solutions. My objective is to create mutiple
child process using the data pull-out from the MYSQL.

Thanks.
Michael
TESTCODE 1
===========
@names=("Sandy", "Sally", "Sarah", "Sue","imgoingcrazy","WHYYYYYYY");
&testmail2(@names);

sub testmail2
{
#databae,content,mailing counter
my @sqlarray = @_;
my $item;
my $cpro=0;
my $arraylen = int @sqlarray;

foreach $item(@sqlarray)
{
my $cpid = fork();
die unless defined $cpid;
if (! $cpid)
{
print "$item<br>\n";
srand();
sleep(int rand(1) + 1);
exit(0);
}
}

#wait for all child process ended
while ((my $cpid = wait()) != -1)
{
$cpro++;
if($cpro >=$arraylen)
{
print "Proceeding to next mailing. Please Wait<br>\n";
last;
}
else
{
print " Entered $cpro<br>";
}
}

return 1;
}

Good result 1
==============
Sandy
Sally
Sarah
Sue
imgoingcrazy
WHYYYYYYY
Entered 1
Entered 2
Entered 3
Entered 4
Entered 5
Proceeding to next mailing. Please Wait

TESTCODE 2
===========

my $dbh = &db_connect($dsn, $user, $password,{InactiveDestroy=>1});
my $sth = $dbh->prepare ("SELECT * FROM $table");
$sth->execute() || quit();

my $hashref;
my $tmpstring;
while ($hashref = $sth->fetchrow_hashref())
{
$tmpstring = "$hashref->{'name'}";
print $tmpstring;
}
$sth->finish();
$dbh->disconnect;

@names=("Sandy", "Sally", "Sarah", "Sue","imgoingcrazy","WHYYYYYYY");
&testmail2(@names);

Fail result 2
=============
Sandy
Sally
Sarah
Sue
imgoingcrazy
WHYYYYYYY
DBI Handle has 1 uncleared child handles. Attempt to free non-existent
shared string. Attempt to free non-existent shared string. Attempt to
free non-existent shared string. Attempt to free non-existent shared
string. dbih_clearcom (h 0x1f35e2c, com 0x352263c): FLAGS 0x11: COMSET
Warn TYPE 2 PARENT DBI::dr=HASH(0x1f35e5c) KIDS 1 (0 Active) IMP_DATA
HASH(0x1f35d6c) in 'DBD::mysql::db' Attempt to free non-existent
shared string during global destruction.
Entered 1
Jul 19 '05 #1
0 1828

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stephen Ferg | last post by:
Seen in the Wall Street Journal, Monday, July 21, 2003, page B1. Lee Gomes' "Portals" technology column: "Two Men, Two Ways to Speak Computerese and Two Big Successes". This is a brief,...
29
by: Bart Nessux | last post by:
Just fooling around this weekend. Wrote and timed programs in C, Perl and Python. Each Program counts to 1,000,000 and prints each number to the console as it counts. I was a bit surprised. I'm not...
4
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # to open a file and write to file # do f=open('xfile.txt','w') # this creates a file "object" and name it f. # the second argument of open can be
0
by: dohnut | last post by:
Here's one for some bored problem solver :) I ran across this earlier today and fixed it, but don't exactly know why. (that usually only happens in C :) I'm using Perl version 5.8.0 btw. ...
2
by: Marty Meyers | last post by:
I have the following line in a php file: $msg= exec("perl $scriptPath/insert.pl $d $u $t 2>&1", $returnVal); Can someone explain the "2>&1" argument? Second problem, this same line of code...
3
by: fritz-bayer | last post by:
Hello, I'm porting a program from php to perl and discovered, that the bitwise operator & seems to work differently, which I don't understand why. I tested it with the values: a=5543039447...
1
by: byrapaneni | last post by:
Hello all; I gathered information from this and several other groups to write a perl & cgi script to display a pdf document. My script works partially and found an issue when testing. Here is...
3
by: jonathan184 | last post by:
The code seems to be working fine for some records but I am thinking it is finding some other records with special characters and so on. I am looking for a way to insert the xml string with escaping...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.