繁体   English   中英

如何在 Perl 的路径中将目录提升两级?

[英]How can I get the directory two levels up in a path in Perl?

如何从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);
my $dir_qfn = "$ENV{IMPORTANT_DIR}/../..";

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM