作者liwei0321 (橘子柠檬汽水)
看板Perl
标题[问题] array_search
时间Tue Apr 8 22:12:58 2008
请问一下 perl是否有类似 php array_serch的语法
@tmp = ("a","b","c");
我要看d是否有在@tmp里面
或是只有使用
for (@tmp){
if ($_ =~ /d/){
return 1;
}else{
return 0;
}
}
这样的方式?!! 谢谢
--
阿台 :哩卖嫩斗亲good喔
阿六仔:如果把我惹毛了,我可不是吃素的
http://www.wretch.cc/blog/liwei0321
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.113.223.192
1F:推 LiloHuang:if use Perl 5.10, it can be if($pattern ~~ @tmp) {} 04/08 22:26
2F:→ liwei0321:感谢版主罗!!!!! thx 04/08 22:40
3F:推 clkao:scalar grep { $_ =~ /d/ } @tmp 04/10 08:09