use File::Find::Random; my $file = File::Find::Random->find(); my $file = File::Find::Random->find('path/'); my $finder = File::Find::Random->new(); $finder->base_path('/foo/bar'); my $file = $finder->find();
Randomly selects a file from a filesystem.
Returns a find object.
Sets or returns the base_path
The biggest function, can be called as a class method or a object method. Automagically will set base_path if passed a parameter. Returns a random file.
If it cannot find a file it will throw an exception of type Error::File::Find::Random.
If the finder finds a empty directory or a finds itself in a place where it has no permissions to descend further, it will throw an error. This might be seen as a bug and might get fixed.
While it is random which file is selected, there is no mechanism in place to counter the imbalance that occurs if you have varying depth of directories. However our use is on very big filesystem with equally distributed directory structures.
Arthur Bergman email@example.com http://opensource.fotango.com/
Copyright 2003 Fotango Ltd All Rights Reserved.
This module is released under the same license as Perl itself.