Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: URL resolve (operations on path etc.)

by harangzsolt33 (Hermit)
on Jul 31, 2022 at 11:31 UTC ( #11145866=note: print w/replies, xml ) Need Help??


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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11145866]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2022-12-08 22:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?