in reply to How to get a true canonical path
$abs_file = File::Spec->rel2abs( $_, $directory ); $canon_file = elimupdir( $abs_file ); sub elimupdir { my $foo = shift; my( $volume, $directories, $file ) = File::Spec->splitpath(File::S +pec->canonpath( $foo )); my( @dur ) = File::Spec->splitdir( $directories ); my @dar; foreach(@dur){ if( $_ eq $updir ){ pop @dar; } else { push @dar, $_; } } return File::Spec->catpath( $volume, File::Spec->catdir( @dar ), $file ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to get a true canonical path
by Anonymous Monk on Jun 21, 2019 at 09:03 UTC | |
by haukex (Archbishop) on Jun 21, 2019 at 10:46 UTC |