在Perl中,如何在一个路径中获得两级目录?
在perl中,如何从一个环境变量向上移动两个目录在Perl中,如何在一个路径中获得两级目录?,perl,Perl,在perl中,如何从一个环境变量向上移动两个目录 sub do_file_tracing { my var = "$ENV{IMPORTANT_DIR}"; } 我想在long/path/to/the/important\u dirlong/path/to/the/important\u dir/../../..//code>创建一个文件,即在long/path/to/使用。例如: use Path::Tiny; my $dir = path($ENV{IMPORTA
sub do_file_tracing {
my var = "$ENV{IMPORTANT_DIR}";
}
我想在long/path/to/the/important\u dir
long/path/to/the/important\u dir/../../..//code>创建一个文件,即在long/path/to/
使用。例如:
use Path::Tiny;
my $dir = path($ENV{IMPORTANT_DIR})->parent(2);
my$dir\u qfn=“$ENV{IMPORTANT\u dir}/./”;
请参阅和中的parent()
方法