in reply to Re^2: 2 sed problems
in thread Yet another substitution problem

Given a path actually exists, problem with a solution not actually changing directories is specified in File::Spec/METHODS ...

canonpath

No physical check on the filesystem, but a logical cleanup of a path.

$cpath = File::Spec->canonpath( $path ) ;

Note that this does *not* collapse x/../y sections into y. This is by design. If /foo on your system is a symlink to /bar/baz, then /foo/../quux is actually /bar/quux, not /quux as a naive ../-removal would give you. If you want to do this kind of processing, you probably want "Cwd"'s "realpath()" function to actually traverse the filesystem cleaning up paths like this.

Otherwise, OP should test|improve on AnomalousMonk's and/or graff's solutions.

Replies are listed 'Best First'.
Re^4: 2 substitution problems
by AnomalousMonk (Archbishop) on Mar 28, 2009 at 22:11 UTC
    Otherwise, OP should test|improve on AnomalousMonk's and/or graff's solutions.
    Actually, the OP should not use those solutions at all – unless it's the solution to use the appropriate function in the Cwd or equivalent module.
      I think you missed "Otherwise", by which I meant to improve on two other solutions when a path does not actually exist on a file system (in case of configuration(s) to be passed around, for example).