首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

Perl 程序出错,Perl初学者

2012-07-26 
Perl 程序出错,Perl菜鸟sub greet{state @names$nameshiftif(@names){print I have seen @names\n}e

Perl 程序出错,Perl菜鸟
sub greet{
  state @names;
  $name=shift;
  if(@names){
  print "I have seen @names\n";
  }  
  else{
  print "You are the first person\n";
  }
  push @names,$name;
}
greet(Cindy);
greet(Tina);
greet(Candy);
greet(Windy);

出错信息
Array found where operator expected at 3.pl line 2,at end of line
  (Missing operator before ?)
syntax error at 3.pl line2, near "state @names"
Excution of 3.pl aborted due to compilation errors.


[解决办法]
use feature qw(state);

热点排行