in reply to File::Find::Closures... help

Hello,
if you just want files over 25 MB, you could try something like this:
use strict; use warnings; use File::Find; my $dir = 'C:\Download'; my $max_size = 25*1024*1024; #25 Mo opendir DIR, $dir or die; my @large_files = grep {stat("$dir/$_"))[7] > $max_size} readdir(DIR); closedir DIR or die; # or recursively find( \&wanted, $dir ); sub wanted { (stat)[7] > $max_size and push @large_files, $File::Find::name; }

HTH,
PooLpi

Replies are listed 'Best First'.
Re^2: File::Find::Closures... help
by mikejones (Scribe) on Dec 20, 2007 at 23:25 UTC
    When I use the recursive method, I ask for input using the <> operator, I input /var and it spits out errors as such:
    Use of uninitialized value in numeric gt (>) at find_hog2 line 21, <> +line 1. =============================== 103643136: /var/opt/ignite/media/image.iso =============================================

    Line 21 is the sub routine wanted code. I run it in debug mode as /var as input and see these errors:

    main::(find_hog2:17): find ( \&wanted, $fs ); DB<2> p DB<2> n Use of uninitialized value in numeric gt (>) at find_hog2 line 20, <> +line 1. main::wanted() called at /opt/perl/lib/5.8.2/File/Find.pm line + 888 File::Find::_find_dir('HASH(0x404f0fe4)','/var',28) called at +/opt/perl/lib/5.8.2/File/Find.pm line 672 File::Find::_find_opt('HASH(0x404f0fe4)','/var') called at /op +t/perl/lib/5.8.2/File/Find.pm line 1175 File::Find::find('CODE(0x403c10b4)','/var') called at find_hog +2 line 17

    When I use /tmp as input I see no errors with some of these files from /var copied over to /tmp??? The script using File::Find::Closures works with no errors or warnings. please help. thank you!