ppti has asked for the wisdom of the Perl Monks concerning the following question:
So, actual path name is platform/data/test.dat. I tried using canonpath() , rel2abs(). But it does not work.platform/process/src/../../data/test.dat
Is there any other funtion? which travels upwards and does the trick?
Thanks ppti
Here is my code.
I want /platform/common/src/line.c#!/usr/bin/perl -w use File::Spec; my $path = "/platform/process/src/../../common/src/line.c"; print $path,"\n"; $new_path = File::Spec->canonpath($path); print $new_path, "\n"; $c_path = File::Spec->rel2abs($path,"/platform"); print $c_path, "\n"; output: /platform/process/src/../../common/src/line.c /platform/process/src/../../common/src/line.c /platform/process/src/../../common/src/line.c
Thanks ppti
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Embedded relative paths
by ikegami (Patriarch) on Dec 12, 2009 at 00:21 UTC | |
by ppti (Initiate) on Dec 12, 2009 at 00:51 UTC |