S
sonet
perl 5.8.6(ActivePerl Build 811)
win32
===========================================
#!perl.exe
use t2;
use threads;
$h{luke}=123;
while ( !$DONE )
{
threads->new( \&do_thread);
}
sub do_thread{
print "===========\n";
handle_connection();
}
==========================================
package t2;
use strict;
use vars '@ISA', '@EXPORT' , '%h';
use Errno qw(EWOULDBLOCK);
use Digest::MD5 qw(md5_hex);
require Exporter;
@ISA = 'Exporter';
@EXPORT = qw(handle_connection %h);
sub handle_connection{
print "abc123\n";
print $h{luke} . "\r\n";
}
1;
============================================
The result is show that.(And this is i want!)
abc123
123
-------------
abc123
-------------
abc123
-------------
abc123
123
123
123
============================================
#!perl.exe
use t2;
use threads;
my %h;
$h{luke}=123;
while ( !$DONE )
{
threads->new( \&do_thread);
}
sub do_thread{
print "===========\n";
handle_connection();
}
============================================
But if i defined my %h,the result is like below.... Why?
I can not understand.
abc123
-------------
abc123
-------------
abc123
....
==============================================
Another problem is how can i share %h in thread? Like above
example?? I have try to use my %h : share , It seem can not to
work!
win32
===========================================
#!perl.exe
use t2;
use threads;
$h{luke}=123;
while ( !$DONE )
{
threads->new( \&do_thread);
}
sub do_thread{
print "===========\n";
handle_connection();
}
==========================================
package t2;
use strict;
use vars '@ISA', '@EXPORT' , '%h';
use Errno qw(EWOULDBLOCK);
use Digest::MD5 qw(md5_hex);
require Exporter;
@ISA = 'Exporter';
@EXPORT = qw(handle_connection %h);
sub handle_connection{
print "abc123\n";
print $h{luke} . "\r\n";
}
1;
============================================
The result is show that.(And this is i want!)
abc123
123
-------------
abc123
-------------
abc123
-------------
abc123
123
123
123
============================================
#!perl.exe
use t2;
use threads;
my %h;
$h{luke}=123;
while ( !$DONE )
{
threads->new( \&do_thread);
}
sub do_thread{
print "===========\n";
handle_connection();
}
============================================
But if i defined my %h,the result is like below.... Why?
I can not understand.
abc123
-------------
abc123
-------------
abc123
....
==============================================
Another problem is how can i share %h in thread? Like above
example?? I have try to use my %h : share , It seem can not to
work!