Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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: (12)
As of 2014-08-22 14:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (158 votes), past polls