Chinaunix
标题:
在perl中有很多以my 开头的行
[打印本页]
作者:
xzh2002
时间:
2003-10-11 12:55
标题:
在perl中有很多以my 开头的行
是什么意思?
作者:
favorit
时间:
2003-10-12 18:48
标题:
在perl中有很多以my 开头的行
用来定义局部变量,perl中使用local或my操作符声明的变量具有局部作用域,如:
{
my $char2 = "in";
print "$char2\n"; #输出:in
}
print $char2; #出了{},char2不可见,不会有输出
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2