Reputation: 815
How to go two directories up from an environment variable in perl?
sub do_file_tracing {
my var = "$ENV{IMPORTANT_DIR}";
}
I want to create a file at long/path/to/the/important_dir
long/path/to/the/important_dir/../../
, that is at long/path/to/
Upvotes: 2
Views: 304
Reputation: 40758
Use Path::Tiny. For example:
use Path::Tiny;
my $dir = path($ENV{IMPORTANT_DIR})->parent(2);
Upvotes: 4