in reply to Re: URL resolve (operations on path etc.)
in thread URL resolve (operations on path etc.)

Could this be resolved with a regex maybe? Like for example:

#!/usr/bin/perl use strict; use warnings; my $PATH = '' . '/' . '/../../../ +'; $PATH =~ tr|/||s; my $PREV = 0; my $LEN; for (;;) { $PATH =~ s/\/[^\/]+\/\.\.//; $LEN = length($PATH); last if ($PREV == $LEN); $PREV = $LEN; } print $PATH;

I put the regex in a for(;;) loop, because adding global flag didn't do what I want:

$PATH =~ s/\/[^\/]+\/\.\.//g;