菜鸟请问
为什么不输出 find 阿。代码如下:
=======================================
my @names = qw /fred barney betty dino Wilma pebbles bam-bamm/;
my $result = &which_element_is("dino", @names);
sub which_element_is{
print "which_element_is\n";
my($what, @array) = @_;
print "\$what is $what\n";
foreach(0..$#array){ #@array 元素的索引
if($waht eq $array[$_]){
print "find\n";
return $_; #找到既返回
}
}
-1; #没有找到元素(此处是可选的)
}
[解决办法]
if($waht eq $array[$_]){ # $what