in reply to Check Directories for Files

hi,

well Perl has got this two cool functions (among others:)) :

opendir(); readdir(); so what you could do is: use strict; use warnings; use File::Copy; opendir (DIR,"./path") || die "$!"; # this opens the directory foreach my $i(readdir DIR){ next if (/\./g || grep{$_=~/$i/g}22..50); move("./path/$i", "/tmp/$i"); # if (-e "./path/$i"); } closedir DIR;
that is it :)

UPDATE:

my bad, tollic is right, so basically what you do is check if the var in question is a regular file or not:

next unless(-f "./path/$i" || !grep{$_=~/$i/g}22..50);
sorry :)

Replies are listed 'Best First'.
Re^2: Check Directories for Files
by toolic (Bishop) on Nov 24, 2009 at 20:03 UTC
    next if (/\./g);
    That will skip all files and sub-directories which contain a literal dot in the name, such as 'file.txt'. It will not skip any directories which do not have a dot, such as 'junk'.