perl - 这个 Perl foreach 是做什么的?

标签 perl

我在理解这个 foreach 的作用时卡住了,我是 perl 编程的新手

-e && print ("$_\n") foreach $base_name, "build/$base_name";

这里的build是目录。谢谢

最佳答案

有人留给你的代码不是很漂亮。 :(

两者之一

for ($basename, "build/$basename") { say if -e }

for my $file ($basename, "build/$basename") {
     say $file if -e $file;
}

会更清楚。

关于perl - 这个 Perl foreach 是做什么的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5790466/

相关文章:

perl - 使用 CTRL + C 终止当前的 LWP 请求

Perl 嵌套结构

string - 使用tr///运算符计算字符串中的字母

postgresql - Dancer2 Auth::Extensible 不接受散列密码

perl - Getopt::Long 在散列选项中推送多个值

perl - 如何让 Capture::Tiny 在失败时打印 stderr 和 stdout?

perl - 有人知道 Perl 验证器吗

macos - 在 Mac 上从 line 读取 gzip line

perl - 为什么 Test::LeakTrace 说这个 Perl 代码正在泄漏内存?

mysql - 在 MacOs Lion 上安装 Perl DBD-mysql-4.021 是否需要 MySQL header?