[英]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.