我在Perl中有以下代码:
next if ++$count == 1;
应该相当于
if (++$count == 1) {
next;
}
如果添加更多条件,有没有办法运行next;
? (即如果++ $ count等于或大于某个其他值?
答案 0 :(得分:9)
我认为像
next if ++$count == 1 or $count > $other_value;
应该只是工作。它虽然非常密集,依赖于增量的副作用和优先顺序
我很想添加括号并移除增量
$count++;
next if ($count == 1) or ($count > $other_value);
答案 1 :(得分:2)
如果要在两个单独的条件下测试"Content-Type: application/json"
的递增值,那么最好在单独的语句中递增它,而不是针对$count
测试一次并且一旦反对++$count
所以你的代码将是
$count