キーワード Cwd::cwd
#!perl -w use strict; use Cwd; my $dir_name = cwd; # カレントディレクトリ名を調べる print "Current directory name is \"$dir_name\".\n"; # 出力例 # Current directory name is "F:/Perl/Doc".
キーワード `cd`
#!perl -w use strict; chomp (my $dir_name = `cd`); # カレントディレクトリ名を調べる print "Current directory name is \"$dir_name\".\n"; # 出力例 # Current directory name is "F:/Perl/Doc".
キーワード chdir
#!perl -w use strict; use Cwd; chdir 'c:'; # カレントディレクトリをc:に移動 my $dir_name = cwd; # カレントディレクトリ名を調べる print "Current directory name is \"$dir_name\".\n"; # 出力 # Current directory name is "C:/".
キーワード blog
#!perl -w use strict; my @all_files = < c:\\* >; print "@all_files\n";
キーワード blog
#!perl -w
use strict;
while(<*.jpg>){
print "$_\n";
}
キーワード
File::Basename::basename
File::Basename::dirname
#!perl -w use strict; use File::Basename qw/ basename dirname /; my $full_path = "c:\\windows\\error.log"; my $base_name = basename $full_path; my $dir_name = dirname $full_path; print "$base_name in $dir_name\n"; # 出力 # error.log in c:\windows
キーワード File::Spec->catfile
#!perl -w
use strict;
use File::Spec;
my $full_path = File::Spec->catfile("c:\\windows", "error.log");
print "$full_path\n";
# 出力
# C:\windows\error.log
キーワード -d
#!perl -w
use strict;
my $path = 'c:/program files';
if(-d $path){ # ディレクトリかテストする
print "$path is directory.\n";
}else{
print "$path is not directory.\n";
}
キーワード mkdir
#!perl -w use strict; mkdir 'test_directory' or die "cannot make a directory.";