http://qs321.pair.com?node_id=11145866


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 = 'http://a.com/a/b/c/d/e.json?something' . '/' . '/../../../ +'; $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;