Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: How to Get the Last Subdirectories

by FunkyMonk (Canon)
on Mar 11, 2010 at 22:27 UTC ( #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

Comment on Re: How to Get the Last Subdirectories
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2016-02-08 20:01 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (283 votes), past polls