Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Array Normalization of File::DirWalk

by Enlil (Parson)
on Feb 23, 2007 at 07:39 UTC ( #601700=note: print w/ replies, xml ) Need Help??


in reply to Array Normalization of File::DirWalk

Since you are printing the directories on the way out you should be able to just do the following:

use strict; use warnings; use File::DirWalk; my $folder = 'E:\test\foldersize\1-folder|E:\test\foldersize\2-folder| +E:\te +st\foldersize\5-folder'; my $depth = 3; my @directory = grep!/^\s*$/, split/\|/, $folder; my @folder; my %dirs; for my $directory (@directory){ my $dw = new File::DirWalk; $dw->onDirLeave( sub { my ($dir) = @_; if ( !exists $dirs{$dir} ) { if( $dir =~ /(.*)\\/ ) { undef($dirs{$1}); } push (@folder, $dir); } return File::DirWalk::SUCCESS; } ); $dw->setDepth($depth); $dw->walk($directory); } print $_,$/ for @folder
and hence it won't print any directory that has any directories in it.


Comment on Re: Array Normalization of File::DirWalk
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2015-07-04 23:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls