这段PHP代码的类比是什么,它在Perl中会做同样的事情?
<?php
if (false !== strpos($_SERVER['REQUEST_URI'], '(foo|bar)')) {
header('410 Gone');
}
?>
我不是PHP用户,但是strpos
看起来像Perl的索引,如果它没有找到字符串,则返回-1(一个越界位置)。
if( -1 != index $some_string, $substring ) { ... }