|
脚本tmp文件如下:
#!/usr/bin/perl
@array=("this","is","freedom");
$count = 0;
while($count<@array){
printf "element $count is $array[$count]\n";
$count=$count+1;
# if($count == 2) //此时以注释掉这句
last;
}
[root@freedom ~]# ./tmp
element 0 is this
这样的话只打印第一行就结束了,和我想的一样。
但是如果我把注释去掉,我本想应该打印出两行的,但是运行时提示有错误
脚本tmp文件如下:
#!/usr/bin/perl
@array=("this","is","freedom");
$count = 0;
while($count<@array){
printf "element $count is $array[$count]\n";
$count=$count+1;
if($count == 2)
last;
}
[root@freedom ~]# ./tmp
syntax error at ./tmp line 10, near ")
last"
Execution of ./tmp aborted due to compilation errors.
这是为什么阿???是我这句话if($count == 2)写的不对吗?? 感觉没错阿。
请高手指点一下我这个perl初学者吧 |
|