Well, if you're not worried about portablity:
!/usr/bin/perl use strict; use warnings; my $somepath = "/var/log/../../home/poletti/../../etc/passwd"; my( @true ); foreach( split( /\//, $somepath ) ) { $_ eq ".." ? pop( @true ) : push( @true, $_ ); } print join( '/', @true ), "\n";
Let the golf begin
In reply to Re: Cleaning up a path
by derby
in thread Cleaning up a path
by polettix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |