# 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();
如对本文有疑问, 点击进行留言回复!!
网友评论