473,769 Members | 6,286 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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","imgoingc razy","WHYYYYYY Y");
&testmail2(@nam es);

sub testmail2
{
#databae,conten t,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($ds n, $user, $password,{Inac tiveDestroy=>1} );
my $sth = $dbh->prepare ("SELECT * FROM $table");
$sth->execute() || quit();

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

@names=("Sandy" , "Sally", "Sarah", "Sue","imgoingc razy","WHYYYYYY Y");
&testmail2(@nam es);

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(0x 1f35e5c) 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 1842

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

Similar topics

1
2510
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, non-technical story on Guido von Rossum, inventor of Python, and Larry Wall, inventor of Perl. I don't think this is available online unless you are a paid subscriber to the WSJ online edition. So here are a few quick quotes
29
3604
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 an expert C or Perl programming expery, I'm most familiar with Python, but can use the others as well. Here are my results: C = 23 seconds Python = 26.5 seconds
4
3066
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
2213
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. Ok, let's start here: I end up with an array that comes from a fetchrow_array() call to MySQL. I return the array to a function.
2
10352
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 when run from the unix command line returns the following error:
3
1625
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 and b=13 Then in perl the expressions:
1
1928
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 my script: =============================================================== #!/bin/perl use CGI qw(:standard *table);
3
3220
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 a bunch of chars This is the message i got DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your M ySQL server version for the right syntax to use near 'd to test@email.com...
0
9587
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9993
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.