我们可以把从目录中取出的所有文件打印到文件中:
#!/usr/bin/perl -wT
use File::copy;
use strict;
print "取文件,请输入文件路径:";
chomp(my $path = <STDIN>);
opendir DIR,$path;
my @dir = readdir DIR;
closedir DIR;
foreach my $file (@dir){
open OUTFILE,">>test.info";
print OUTFILE "$file\n"; //改变了输出句柄
close OUTFILE;
}