Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: URL resolve (operations on path etc.)

by haukex (Archbishop)
on Jul 31, 2022 at 07:52 UTC ( #11145864=note: print w/replies, xml ) Need Help??

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

use warnings; use strict; use URI; my $x = ''; my $y = '../../../'; my $u = URI->new($y); print $u->abs($x), "\n"; __END__

Replies are listed 'Best First'.
Re^2: URL resolve (operations on path etc.)
by bliako (Monsignor) on Jul 31, 2022 at 08:03 UTC

    Thanks haukex++ (I swear last night abs was not working!!!!!!)

    EDIT!: ouchhhh I was doing the reverse!!!!!:

    # this is wrong, note new($x)!! abs($y) it should be the reverse my $u = URI->new($x); # this is wrong print $u->abs($y), "\n"; # this is wrong

    Edit2: that's definetely an X-Y problem hehe

Re^2: URL resolve (operations on path etc.)
by ikegami (Patriarch) on Aug 01, 2022 at 22:50 UTC
Re^2: URL resolve (operations on path etc.)
by harangzsolt33 (Hermit) on Jul 31, 2022 at 11:31 UTC
    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;

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2022-11-30 21:13 GMT
Find Nodes?
    Voting Booth?