opendir 在 Perl 6 中如何工作?
有人可以告诉我,为什么“opendir”不起作用?
#!/usr/bin/env perl6
use v6;
my $file = 'Dokumente/test_file';
if ( my $fh = open $file, :r ) {
for $fh.lines -> $line {
say $line;
}
} else {
say "Could not open '$file'";
}
my $dir = 'Dokumente';
my $dh = opendir $dir err die "Could not open $dir: $!";
输出:
你好,世界!
2号线。
最后一行。找不到不存在的子目录&opendir
当前指令:“_block14”pc 29 (EVAL_1:0)
从 Sub '!UNIT_START' pc 1163 (src/glue/run.pir:20) 调用
从 Sub 'perl6;PCT;HLLCompiler;eval' pc -1 ((未知文件):-1) 调用
从 Sub 'perl6;PCT;HLLCompiler;evalfiles' pc 1303 调用 (compilers/pct/src/PCT/HLLCompiler.pir:707)
从 Sub 'perl6;PCT;HLLCompiler;command_line' pc 1489 调用 (compilers/pct/src/PCT/HLLCompiler.pir:794)
从 Sub 'perl6;Perl6;Compiler;main' pc -1 ((未知文件):-1) 调用
Can someone tell me, why the "opendir" doesn't work?
#!/usr/bin/env perl6
use v6;
my $file = 'Dokumente/test_file';
if ( my $fh = open $file, :r ) {
for $fh.lines -> $line {
say $line;
}
} else {
say "Could not open '$file'";
}
my $dir = 'Dokumente';
my $dh = opendir $dir err die "Could not open $dir: $!";
Output:
Hello, World!
Line 2.
Last line.Could not find non-existent sub &opendir
current instr.: '_block14' pc 29 (EVAL_1:0)
called from Sub '!UNIT_START' pc 1163 (src/glue/run.pir:20)
called from Sub 'perl6;PCT;HLLCompiler;eval' pc -1 ((unknown file):-1)
called from Sub 'perl6;PCT;HLLCompiler;evalfiles' pc 1303 (compilers/pct/src/PCT/HLLCompiler.pir:707)
called from Sub 'perl6;PCT;HLLCompiler;command_line' pc 1489 (compilers/pct/src/PCT/HLLCompiler.pir:794)
called from Sub 'perl6;Perl6;Compiler;main' pc -1 ((unknown file):-1)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Perl6 现在已经准备好了。这样我们就可以对这个非常老的问题给出正确的答案了。
Perl6 中不再有 opendir。但感谢许多使用 Perl 6 的人,打开目录现在非常简单。
正如 perl - dir doc 所说:
打开目录只需键入:
并使用过滤器:
所以你可以忘记 opendir、readdir、grep 等。
Perl6 is ready now. So we can give a correct answer to this very old question.
There is no more opendir in Perl6. But thanks to many people who work on Perl 6, open a dir is now very simple.
As perl - dir doc says:
Opening a directory requires just to type:
And with a filter:
So you can forget opendir, readdir, grep and other.
opendir 还没有实现。请发送邮件至 [email protected] 来提交错误报告。
opendir is just not yet implemented. Please file a bug report by sending a mail to [email protected].
我没有 Perl 6,但看起来您错误地调用了 opendir。这个 Perl 片段对我有用:
I don't have Perl 6, but it looks like you are calling opendir incorrectly. This perl snippet works for me: