如何从 perl 中的环境变量向上移动两个目录?
sub do_file_tracing {
my var = "$ENV{IMPORTANT_DIR}";
}
我想在 long/path/to/the/important_dir
long/path/to/the/important_dir/../../
中创建一个文件,那是在 long/path/to/
最佳答案
使用Path::Tiny .例如:
use Path::Tiny;
my $dir = path($ENV{IMPORTANT_DIR})->parent(2);
关于perl - 我怎样才能在 Perl 的路径中获得两个级别的目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64861826/