Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Collapsing paths

by oha (Friar)
on Dec 05, 2007 at 12:52 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-19 21:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found