Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Array Normalization of File::DirWalk

by Enlil (Parson)
on Feb 23, 2007 at 07:39 UTC ( [id://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.

Log In?
Username:
Password:

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

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

    No recent polls found