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();
相關(guān)文章
perl從文件中讀取數(shù)據(jù)并輸出的實現(xiàn)代碼
perl從文件中讀取數(shù)據(jù)并輸出,附一個蛋白質(zhì)序列的讀取,有需要的朋友可以參考下2013-02-02

