Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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

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 exploiting the Monastery: (17)
As of 2016-10-26 18:25 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (345 votes). Check out past polls.