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);