H
hendedav
Gang,
I am having problems passing an array of directories to find. If
I generate the array manually the code works flawlessly. If I let the
application create the array, it bombs with errors "can't stat ...:
invalid argument" even though both show the same results. Here is the
snipet of code:
both $params{'include'} and $params{'exclude'} have values like: "/
somedir/child|/anotherdir/etc|/dir/sub" with the "|" character
seperating the directories.
if (defined $params{'include'}) { (@include) = split(/\|/,
$params{'include'}); } else { return 1; } # seperate all the
"include" directories and files into an array
if (defined $params{'exclude'}) { @exclude = split(/\|/,
$params{'exclude'}); } # same for the "excluded" ones
for (my $i=0; $i<$#include+1; $i++) { # remove the preceeding /
from the entries in the include array
$include[$i] =~ s/\///;
print "$i is '$include[$i]'\n";
}
# if the below are uncommented and run, the application works
#$include[0] = "Webpage\ Projects/foo.ver4";
#$include[1] = "Webpage\ Projects/foobar";
find (sub {
if (-d "$_") { return 1; } # if the value IS a directory, then
skip to the next one
if (int(-M $_) >= $totaldays) { print " removing $_\n"; }
}, @include); # traverses the directory structure to find
files to be removed (might need to use "unlink $File::Find::name;")
}
Any help would greatly be appreciated.
Thanks,
Dave
I am having problems passing an array of directories to find. If
I generate the array manually the code works flawlessly. If I let the
application create the array, it bombs with errors "can't stat ...:
invalid argument" even though both show the same results. Here is the
snipet of code:
both $params{'include'} and $params{'exclude'} have values like: "/
somedir/child|/anotherdir/etc|/dir/sub" with the "|" character
seperating the directories.
if (defined $params{'include'}) { (@include) = split(/\|/,
$params{'include'}); } else { return 1; } # seperate all the
"include" directories and files into an array
if (defined $params{'exclude'}) { @exclude = split(/\|/,
$params{'exclude'}); } # same for the "excluded" ones
for (my $i=0; $i<$#include+1; $i++) { # remove the preceeding /
from the entries in the include array
$include[$i] =~ s/\///;
print "$i is '$include[$i]'\n";
}
# if the below are uncommented and run, the application works
#$include[0] = "Webpage\ Projects/foo.ver4";
#$include[1] = "Webpage\ Projects/foobar";
find (sub {
if (-d "$_") { return 1; } # if the value IS a directory, then
skip to the next one
if (int(-M $_) >= $totaldays) { print " removing $_\n"; }
}, @include); # traverses the directory structure to find
files to be removed (might need to use "unlink $File::Find::name;")
}
Any help would greatly be appreciated.
Thanks,
Dave