Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Collapsing paths

by oha (Friar)
on Dec 05, 2007 at 12:52 UTC ( #655078=note: print w/replies, xml ) Need Help??


in reply to Collapsing paths

if you are interested in doing it with regexp:
{ $path =~ s{(^|/)(\w+/\.\./|\./)}{$1} and redo }
which collapses ./ and <dir>/../

Oha

Replies are listed 'Best First'.
Re^2: Collapsing paths
by ikegami (Patriarch) on Dec 05, 2007 at 21:53 UTC

    It wouldn't hurt to make the loop more obvious.

    1 while $path =~ s{(^|/)(\w+/\.\./|\./)}{$1};

    It's even shorter.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2022-01-25 17:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (67 votes). Check out past polls.

    Notices?