$string = ‘fin_helm’;
$array = array(’full_plate’,'manteau’,'boots’,'two_handed_sword’,'fin_helm’);
if(in_array($string, $array))
{
print “$string is in the array”;
}
?>
#!/usr/bin/perl
my $string = ‘fin_helm’;
my @array = qw/full_plate manteau boots two_handed_sword fin_helm/;
if(grep $_ eq $string, @array)
{
print “$string is in the array”;
}
grep语法
grep BLOCK LIST
grep EXPR, LIST
ex:
Reference from http://mach.debagua.com/archives/2007/0622_000544.html
$shopid_list = "950272 1618616 1626010 1620041 1613047 1843905 2555854 1612225 1615202 1329343 2439204 300626 1623950 2630407 2685660 1611501 301721 1864877 1672871 302296 904914 1685735 2815106 974037 1614867 2684563 1866639 1632518 1882639 1639995 1706732 1638243 1774685 2256527 1649382 1621969 941962 974113 2768569 2561992 302559 2612701 1709907 1713725 940505 1993346 301860 2177558 1906324 1504229 1637618 1638367 2128013 1867004 911219 946878 1592792 2506425 1619153 1653338 1639030 1643759 2692553 1693809";
$tmp = "950272";
if(( $shopid_list =~ m/\b$tmp\b/g)){
}
沒有留言:
張貼留言