if (not -d $My_DIR) {
mkdir $My_DIR;
}
Reference: http://stevemorin.blogspot.com/2009/09/perl-test-if-directory-exists.html
$work_dir = "D:\\work";
if (scalar <$work_dir\\*>) {
print "Something is in there\n";
}
Get directory file list example:
$work_dir = "D:\\work";
@files = <$work_dir\\*>;
print @files;
Reference: http://forums.devshed.com/perl-programming-6/using-perl-to-list-files-in-a-directory-344889.html
Get all subdirectory file list example:
use File::Find;
find ( sub { next unless -f; print $File::Find::name,"\n" }, "." );
Reference:
http://www.perlmonks.org/?node_id=535340
http://perldoc.perl.org/File/Find.html
Move files example:
use File::Copy;
$src_file = "D:\\src";
$dst_file = "D:\\dst";
move($src_file, $dst_file);
Reference: http://www.tizag.com/perlT/perlcopyfiles.php
沒有留言:
張貼留言