Likewise for File::Find prune set to 1?
$ find2perl /dirname -size +4092k -ls -prune
thank you
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
oryann9> $ find2perl /dirname -size +4092k -ls -prune
Since -prune is *after* the condition of -size, you're setting
prune only for VERY VERY LARGE directories. Is that your
intent?
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Since -prune is *after* the condition of -size, you're setting
prune only for VERY VERY LARGE directories. Is that your
intent?
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
No, but good point. My intent was to determine when -prune was set on the CLI what the De-parsed code told me, 1==true, 0==false because when I run this code below prune = 0 is not working, its descending down "/".
use strict ;
use warnings ;
use File::Find ;
use File::Find::Closures qw(find_by_min_size) ;
<snip>
find_me ( $fs, 0 );
<snip>
sub find_me {
use Data::Dumper;
my $fs = shift;
print "FS from sub\t$fs\n";
print Dumper(local $File::Find::prune = shift); ##-- localize prune to just this block --##
use constant MAX_SIZE => (25*1024*1024) ;
use constant DIVISOR => (1024) ;
my ( $wanted, $list ) = find_by_min_size ( MAX_SIZE ) ;
File::Find::find ( { wanted => $wanted, }, $fs ) ;
@large_files = $list->() ;
@sorted_large_files =
sort { -s $b <=> -s $a }
@large_files ;
} ##-- End sub --##
<snip>
thx for the reply!
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
oryann9> No, but good point. My intent was to determine when -prune was set on
oryann9> the CLI what the De-parsed code told me, 1==true, 0==false because
oryann9> when I run this code below prune = 0 is not working, its descending
oryann9> down "/".
You're misusing it. Set it within the wanted() routine when you're looking at
a directory that you don't want to descend. It'll be cleared to 0 before
calling wanted(), so setting it before calling find() is completely useless.
oryann9> No, but good point. My intent was to determine when -prune was
set on
oryann9> the CLI what the De-parsed code told me, 1==true, 0==false
because
oryann9> when I run this code below prune = 0 is not working, its
descending
oryann9> down "/".
You're misusing it. Set it within the wanted() routine when you're
looking at
a directory that you don't want to descend. It'll be cleared to 0
before
calling wanted(), so setting it before calling find() is completely
useless.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
0095
<mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
-
__OUTPUT__
main::(find_hog:47): if ( $fs eq "/" ) { # only if the root directory
DB<1> print $fs
/
DB<2> n
main::(find_hog:48): find_me ( $fs, 0 );
DB<2> n
print caller find_me
main::(find_hog:61): my ( @sorted_large_files, @large_files ) ;
DB<2>
main::(find_hog:80): if (@sorted_large_files) {
DB<2> print caller find_me
invalid top directory at /opt/perl/lib/5.8.2/File/Find.pm line 568, <> line 1.
DB<3> print $fs
/
DB<4> n
main::(find_hog:81): my %meta ;
DB<4> n
main::(find_hog:82): for my $file (@sorted_large_files) {
DB<4> n
main::(find_hog:83): $meta{$file} = {
main::(find_hog:84): 'uid' => (stat($file))[4],
main::(find_hog:85): 'gid' => (stat($file))[5],
main::(find_hog:86): 'sz' => (stat($file))[7],
main::(find_hog:87): 'mod' => (stat($file))[9],
DB<4> print $file
/data/data01/recovery/archives/dubhdv04/2007-11-15,11:21
DB<5>
/data/... should not be appearing if prune set to false, or 0.
__CODE__
Is this what you mean on line 9? I tried and it does not seem to work, meaning it still descending.
1 sub find_me {
2 use Data::Dumper;
3 my $fs = shift;
4 #local $File::Find::prune = shift; ##-- localize prune to just this block --##
5 #my @directory = ($fs) ;
6 use constant MAX_SIZE => (25*1024*1024) ;
7 use constant DIVISOR => (1024) ;
8 my ( $wanted, $list ) = find_by_min_size ( MAX_SIZE ) ;
9 File::Find::find ( { wanted => $wanted, prune => $File::Find::prune = shift}, $fs ) ;
10 @large_files = $list->() ;
11
12 @sorted_large_files =
13 sort { -s $b <=> -s $a }
14 @large_files ;
15
16 } ##-- End sub --##
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
> > You're misusing it. Set it within the wanted() routine when you're
> Is this what you mean on line 9? I tried and it does not seem to work,
> meaning it still descending.
>
> 1 sub find_me {
> 2 use Data::Dumper;
> 3 my $fs = shift;
> 4 #local $File::Find::prune = shift; ##-- localize prune to just this block --##
> 5 #my @directory = ($fs) ;
> 6 use constant MAX_SIZE => (25*1024*1024) ;
> 7 use constant DIVISOR => (1024) ;
> 8 my ( $wanted, $list ) = find_by_min_size ( MAX_SIZE ) ;
> 9 File::Find::find ( { wanted => $wanted, prune => $File::Find::prune = shift}, $fs ) ;
> 10 @large_files = $list->() ;
> 11
> 12 @sorted_large_files =
> 13 sort { -s $b <=> -s $a }
> 14 @large_files ;
> 15
> 16 } ##-- End sub --##
That's not within your wanted() routine.
File::Find will call your wanted() code many times. Your code will
normally leave prune alone. At some point, your code will find itself
dealing with a directory into which you don't want to search, so your
code will set prune to a true value; this will cause File::Find to say
to itself, "Ho ho! You don't want to go deeper than here! Your wish is
my command!" It will consider that directory to be complete, and go on
to the next, thereby pruning the search tree.
Hope this helps!
--Tom Phoenix
Stonehenge Perl Training
>--
>Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
>0095
><mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
>Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
-
Is this what you mean on line 9? I tried and it does not seem to work,
meaning it still descending.
1 sub find_me {
2 use Data::Dumper;
3 my $fs = shift;
4 #local $File::Find::prune = shift; ##-- localize prune
to just this block --##
5 #my @directory = ($fs) ;
6 use constant MAX_SIZE => (25*1024*1024) ;
7 use constant DIVISOR => (1024) ;
8 my ( $wanted, $list ) = find_by_min_size ( MAX_SIZE ) ;
9 File::Find::find ( { wanted => $wanted, prune =>
$File::Find::prune = shift}, $fs ) ;
10 @large_files = $list->() ;
11
12 @sorted_large_files =
13 sort { -s $b <=> -s $a }
14 @large_files ;
15
16 } ##-- End sub --##