#!/usr/bin/perl use strict; use warnings; use File::Spec; my $somepath = "/var/log/../../home/poletti/../../etc/rc.d"; my @true; $somepath = "/../../../"; # Let's pretend $somepath is a directory... or is it? :) /^\.\./ ? pop( @true ) : push( @true, $_ ) foreach( File::Spec->splitdir($somepath) ); print File::Spec->catdir(@true), "\n";
Flavio (perl -e "print(scalar(reverse('ti.xittelop@oivalf')))")
Don't fool yourself.In reply to Re^2: Cleaning up a path
by polettix
in thread Cleaning up a path
by polettix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |