Perl 的后缀 `for` 语法记录在哪里? [英] Where is Perl's postfix `for` syntax documented?

查看:50
本文介绍了Perl 的后缀 `for` 语法记录在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近遇到了以下代码片段

I recently came across the following code snippet

$count_stuff{$_}++ for @stuff;

例如,使用散列来计算数组中字符串的出现次数是一种非常方便的方法.我了解如何它的工作原理,但不了解它为什么它的工作原理.我找不到这种使用 for 的方式的文档.

It's a pretty convenient way to use a hash to count occurrences of strings in an array for example. I understand how it works, but not why it works. I can not find the documentation for this way of using for.

为什么有效?文档在哪里?

Why does it work? And where is the documentation?

推荐答案

它记录在perlsyn"手册页的 语句修饰符(讨论后缀语法)和Foreach Loops (这解释了for"和foreach"是同义词).

It is documented in the "perlsyn" man page, under Statement Modifiers (which talks about the postfix syntax) and under Foreach Loops (which explains that "for" and "foreach" are synonyms).

这篇关于Perl 的后缀 `for` 语法记录在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆