Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://601700]
help
Chatterbox?
[james28909]: how can i write a while loop on one line (in a script) something like print "this\n" && print "that" && <DATA> && print the other\n" && next if /this matches/ while <DATA>?
[james28909]: i have tried with && and and and have tried to rearrange the functions as well to no avail
[shmem]: use parens to group expressions
[shmem]: you can't use next in a statement modifier
[shmem]: next requires a BLOCK

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2018-05-20 18:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?