in reply to Re: Absolute pathnames from relative?
in thread Absolute pathnames from relative?
sub File::Spec::un_upwards { my($self, $foo) = @_; $foo = $self->canonpath( $foo ); my $updir = $self->updir(); return $foo if -1 == index $foo, $updir; my( $volume, $directories, $file ) = $self->splitpath($foo); my @dar; foreach($self->splitdir( $directories )){ if( $_ eq $updir ){ if(@dar){# in case the path is relative, ie ../fo/bar/base pop @dar; } else { push @dar, $_; } } else { push @dar, $_; } } return $self->catpath( $volume, $self->catdir( @dar ), $file ); }
|
|---|