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

Re: Parent directory - regex

by davidj (Priest)
on Jun 17, 2004 at 12:39 UTC ( #367598=note: print w/replies, xml ) Need Help??


in reply to Parent directory - regex

Here's a way to do it with a regex

#!\usr\bin\perl use strict; my $myDirectory; my $parent; $myDirectory = "/dir1/dir2/dir3/dir4/dirLast//"; # with '/' after dirLast ($parent) = $myDirectory =~ m#(.+)/#; print "$parent\n"; # without '/' after dirLast ($parent) = $myDirectory =~ m#(.+)//#; print "$parent\n"; exit;

davidj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://367598]
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-12-03 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?