如何在Perl中设置状态码,类似于在PHP中工作的方式?



这段PHP代码的类比是什么,它在Perl中会做同样的事情?

<?php 
if (false !== strpos($_SERVER['REQUEST_URI'], '(foo|bar)')) {
header('410 Gone');
} 
?>

我不是PHP用户,但是strpos看起来像Perl的索引,如果它没有找到字符串,则返回-1(一个越界位置)。

if( -1 != index $some_string, $substring ) { ... }

最新更新