作者jjandy (馒头)
看板Perl
标题[问题] perl学书手册第五版习题解答4-4
时间Sat Apr 9 00:57:30 2011
我在做perl学习手册第五版第四章习题第4题时。
照着习题解答打
#!/usr/bin/perl
greet('Fred');
greet('Barney');
sub greet {
state $last_person; #←就是这一行
my $name = shift;
print "Hi $name!";
if(defined $last_person) {
print "$last_person is also here!\n";
}
else {
print "You are the first one here!\n";
}
$last_person = $name;
}
在win7,cmd下跑会出现如下error
Can't call method "state" on an undefined value at 222 line 5.
请问有谁知道为什麽吗?
谢谢!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.113.144.77
※ 编辑: jjandy 来自: 140.113.144.77 (04/09 00:57)
1F:推 abliou:请用use 5.010 04/09 01:23
2F:→ jjandy:感谢!问题已解决。 04/09 02:11