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

Re: How to Get the Last Subdirectories

by FunkyMonk (Chancellor)
on Mar 11, 2010 at 22:27 UTC ( [id://828152]=note: print w/replies, xml ) Need Help??


in reply to How to Get the Last Subdirectories

use Data::Dump 'pp'; my @dirs = qw( tmp/a tmp/a/b tmp/a/b/c tmp/a/b/c/e tmp/a/b/d tmp/a/b/d/g tmp/a/b/d/g/h tmp/a/b/d/g/i tmp/a/b/k ); my %empty; for (@dirs) { $empty{$_} = 1; # assume empty s!/[^/]+$!!; # find parent delete $empty{$_}; # and remove it } pp keys %empty; __END__ ("tmp/a/b/k", "tmp/a/b/d/g/h", "tmp/a/b/c/e", "tmp/a/b/d/g/i")


Unless I state otherwise, all my code runs with strict and warnings

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-16 07:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found