huhuegg's BLOGhuhuegg.blog.chinaunix.net
huhuegg
全部博文(60)
2012年(7)
2011年(35)
2010年(8)
2009年(7)
2008年(3)
ablewen
小雅贝贝
微风送来
ljf3368
23号
liangbo
yaoqimin
joeysky
ychuang6
zsgd
amos7891
scriptsh
liangwav
wangchen
分类:
2008-10-21 16:56:37
#!/usr/bin/perl -w#test_server run under administratoruse strict;use IPC::Shareable;my $glue = 'test.key';my %options = ( create => 1, exclusive => 0, mode => 0644, destroy => 1,);my @arr;tie @arr, 'IPC::Shareable', $glue, { %options } or die "server: tie failed\n";@arr = ();while (1) { print "Input:"; my $input=<STDIN>; chomp $input; if (defined $input) { push(@arr,$input); } print "\@arr:@arr\n";}exit;
#!/usr/bin/perl -w#test_client run under administratoruse strict;use IPC::Shareable;my $glue = 'test.key';my %options = ( create => 0, exclusive => 0, mode => '0644', destroy => 0, size=>65536 #size must less then 65536 );my @arr;my $ipch=tie @arr, 'IPC::Shareable', $glue, { %options } or die "client: tie failed\n";while(1) { if (scalar @arr > 0) { $ipch->shlock; my $str=shift @arr; $ipch->shunlock; print "output:$str\n"; } else { sleep 3; }}exit;
上一篇:[Perl] perl调用c的so动态链接库
下一篇:[Linux][tty][Perl]Term::TtyRec
登录 注册