in reply to Sub in a Sub & Recursion
sub Get_Saves { my @files; #Just a small mod here. Call FileName since it now #returns a suitable closeure, and pass in the #reference to @files so that FileName knows #where to add stuff. @files=find(FileName(\@files),"/usr/local/apache/htdocs/service +/"); return \@files, $#files+1; }##END Get_Saves sub FileName { my $files_ref=shift; #Use reference to array return sub { unless (($_ eq "." )or ($_ eq "temp.svd")){ push @{$files_ref}, $_; } #removed this since returning anything from the #wanted function does not really make any sence(See #File::Find) #return @files } }
The solution came to me months later when I learned about closeures. Unfortunately I had quit the company by then, so I couldnt tell him how he had wasted his time reimplementing File::Find. Anyway, I guess the moral is something like:Whenever File::Find doesnt seem to do all you want, start reading about closeures again.
GoldClaw
|
|---|