代码如下

use strict;
use warnings;

# Print all files in a directory
sub print_files {
my $dir = 'd:/code';
opendir DIR, $dir or die $!;
my @files = readdir DIR;
chdir $dir; # Use chdir or -f will not work, since -f need absolutely path
foreach my $file (@files) {
if (-f $file) {
print "$file\n";
}
}
closedir DIR;
}

&print_files();

1;

==

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-08
猜你喜欢
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
  • 2022-02-22
相关资源
相似解决方案