Perl使用chdir的实例代码
代码如下:
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();
相关推荐
边城客栈学无止境 2020-07-05
Walter的学习笔记 2020-07-04
A宇 2020-06-14
边城客栈学无止境 2020-06-10
邓博学习笔记 2020-06-03
davidliu00 2020-05-26
ShiShuo 2020-05-16
Aggressivesnail 2020-05-10
ShiShuo 2020-04-26
hanxingwang00 2020-04-22
davidliu00 2020-03-06
ShiShuo 2020-03-06
ShiShuo 2020-03-05
Aggressivesnail 2020-02-28
aaLiweipeng 2020-02-01
amberom 2020-01-16
Walter的学习笔记 2020-01-06