Chinaunix首页 | 论坛 | 博客
  • 博客访问: 53227
  • 博文数量: 11
  • 博客积分: 590
  • 博客等级: 中士
  • 技术积分: 140
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-15 17:42
文章分类

全部博文(11)

文章存档

2010年(11)

我的朋友

分类:

2010-09-29 00:28:03

The kind of subroutine that can access all lexical variables that existed at the time we declared it is called a closure (a term borrowed from the world of mathematics). In Perl terms, a closure is just a subroutine that references a lexical variable that has gone out of scope.
闭包就是能引用在程序范围外的词法变量的子程序。
例:$count
#!/usr/bin/perl -w
use strict;
{
my $count = 10;
sub count_one{$count--};
sub count_two{$count};
}
count_one();
print 'we have seen', count_two() ,"counts!\n"
 
阅读(906) | 评论(1) | 转发(0) |
0

上一篇:MFS的配置

下一篇:施瓦茨变换(排序)

给主人留下些什么吧!~~

chinaunix网友2010-09-29 11:30:44

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com