I can't tell by the code you've given above but I suspect when you're looking for a single file, you're calling it in scalar context which according to the docs will return the count of the files found rather than the list of files found.
Here's an example of how you might use it:
sub FindFile
{
my $file = shift;
my @directories = @_;
my $pathtofile;
unshift(@directories,"./");
# this could still cause scalar context...
# return File::Finder->name($file)->in(@directories);
# this forces list context
return @{[File::Finder->name($file)->in(@directories)]};
};
Disclaimer: I've never used this module before 5 minutes ago
Updated: returned the value from the File::Finder call directly rather than storing it in an array. I had first intended to only return the first element since the OP was only expecting one response and the name of the sub is
FindFile not
FindFiles but it's probably better to let the caller deal with multiple results rather than assume they only want one... (Thanks for the compliment merlyn :-)
Updated (again): well tye pointed out the problem with my fix (as suggested by merlyn) so I've fixed it again...