in reply to Sub in a Sub & Recursion

Heres a good use for closeures. The way File::Find works there are no good way to pass extra arguments into the wanted subroutine without using closeures. So for your example you could do something like this:
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 } }

A few years back a colleuge of mine was horrified of the File::Find module, since you basically had to use "global" variables to be able to pass arguments in to it. I was sure that couldnt be so, but I didnt know/understand closeures at the time. He ended up writing his own find routine, and I twisted my brain for days on how to do this with File::Find.

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