thread hash bug?
[email protected] ("Wong, Danny H.") Tue, 3 Jun 2008 15:30:30 -0700
| Newsgroups | perl.ithreads |
|---|---|
| Message-ID | <D331130DD3DA194B96EF57DA3415F50A024C42CE@SAUSCUPEXCH01.corp.sa.net> |
------_=_NextPart_001_01C8C5C9.6E82BC09
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hi GURUS,
I'm trying to created a hash of array inside a thread, but the hash
loses all its keys/values when leaving the function. Is there a bug in
using a hash inside a thread? Any ideas?
foreach my $i ( 1..3){
push (@BUILD_THREADS, threads->create(\©, $i));
}
foreach my $THREAD (@BUILD_THREADS)
{
my @DATA =3D $THREAD->join();
}
sub COPY
{
my ($i) =3D @_;
copy ( ${SOURCE}, "${DESTINATION}_${i}");
push @{$STORE_BUILD_RESULTS{"flintstones"}}, "${DESTINATION}_${i}";
while ( my ($KEY, $VALUE) =3D each (%STORE_BUILD_RESULTS))
{
print "KEY, VALUE is $KEY, @$VALUE\n"; #I get correct print out.
# $COMPLETED_BUILDS =3D STORE_BUILD_RESULTS
}
}
while ( my ($KEY, $VALUE) =3D each (%STORE_BUILD_RESULTS)) #The hash is
empty. Nothing gets printed out.
{
print "KEY, VALUE is $KEY, $VALUE\n";
# $COMPLETED_BUILDS =3D STORE_BUILD_RESULTS
}
- - - - - Cisco =
- - - - -
This e-mail and any attachments may contain information which is confiden=
tial,
proprietary, privileged or otherwise protected by law. The information is=
solely
intended for the named addressee (or a person responsible for delivering =
it to
the addressee). If you are not the intended recipient of this message, yo=
u are
not authorized to read, print, retain, copy or disseminate this message o=
r any
part of it. If you have received this e-mail in error, please notify the =
sender
immediately by return e-mail and delete it from your computer.
------_=_NextPart_001_01C8C5C9.6E82BC09--