【发布时间】:2017-10-15 04:34:09
【问题描述】:
learn.perl.org 有 reading the contents of a directory 的示例代码:
#!/usr/bin/perl
use strict;
use warnings;
use Path::Tiny;
my $dir = path('foo','bar'); # foo/bar
# Iterate over the content of foo/bar
my $iter = $dir->iterator;
while (my $file = $iter->next) {
# See if it is a directory and skip
next if $file->is_dir();
# Print out the file name and path
print "$file\n";
}
使用 Perl 5.18.2 和 Path::Tiny of DAGOLDEN/Path-Tiny-0.104.tar.gz 运行它,我得到一个错误:
无法在 read_directory.pl 的 unblessed 引用上调用方法“next” 第 11 行。
【问题讨论】:
标签: perl