2005-07-22 13:04:36 +02:00
|
|
|
This module simplifies the routine job of selecting a random file. (As you
|
|
|
|
can find at CGI scripts). It's done, because it's boring (and
|
2008-05-23 23:18:39 +02:00
|
|
|
error prone), always to write something like
|
2005-07-22 13:04:36 +02:00
|
|
|
|
|
|
|
my @files = (<*.*>);
|
|
|
|
my $randf = $files[rand @files];
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
opendir DIR, " ... " or die " ... ";
|
|
|
|
my @files = grep {-f ...} (readdir DIR);
|
|
|
|
closedir DIR;
|
|
|
|
my $randf = $files[rand @files];
|
|
|
|
|
|
|
|
It also becomes very boring and very dangerous to write randomly selection
|
|
|
|
for subdirectory searching with special check-routines. The simple
|
|
|
|
standard job of selecting a random line from a file is implemented, too.
|
|
|
|
|
|
|
|
WWW: http://search.cpan.org/dist/File-Random/
|