README
1File::Random Version 0.21
2=========================
3NAME
4 File::Random - Perl module for random selecting of a file
5
6INSTALLATION
7
8The classic
9
10 perl Makefile.PL
11 make
12 make test
13 make install
14
15will do this job.
16
17SYNOPSIS
18 use File::Random qw/:all/;
19
20 my $fname = random_file();
21
22 my $fname2 = random_file(-dir => $dir);
23
24 my $random_gif = random_file(-dir => $dir,
25 -check => qr/\.gif$/,
26 -recursive => 1,
27 -follow => 1);
28
29 my $no_exe = random_file(-dir => $dir,
30 -check => sub {! -x});
31
32 my @jokes_of_the_day = content_of_random_file(-dir => '/usr/lib/jokes');
33 my $joke_of_the_day = content_of_random_file(-dir => '/usr/lib/jokes');
34 # or the shorter
35 my $joke = corf(-di r => '/usr/lib/jokes');
36
37 my $word_of_the_day = random_line('/usr/share/dict/words');
38 my @three_words = random_line('/usr/share/dict/words',3);
39 # or
40 my ($title,$speech,$conclusion) = random_line('/usr/share/dict/words');
41
42DESCRIPTION
43 This module simplifies the routine job of selecting a random file. (As
44 you can find at CGI scripts).
45
46 It's done, because it's boring (and errorprone), always to write
47 something like
48
49 my @files = (<*.*>);
50 my $randf = $files[rand @files];
51
52 or
53
54 opendir DIR, " ... " or die " ... ";
55 my @files = grep {-f ...} (readdir DIR);
56 closedir DIR;
57 my $randf = $files[rand @files];
58
59 It also becomes very boring and very dangerous to write randomly
60 selection for subdirectory searching with special check-routines.
61
62 The simple standard job of selecting a random line from a file is
63 implemented, too.
64
65DEPENDENCIES
66 This module requires these other modules and libraries:
67
68 Want
69
70 For the tests are also needed many more modules:
71
72 Test::More
73 Test::Exception
74 Test::Class
75 Set::Scalar
76 File::Temp
77 Test::Warn
78 Test::ManyParams
79
80 All these modules are needed only for the tests.
81 You can work with the module even without them.
82 These modules are only needed for my test routines,
83 not by the File::Random itself.
84 (However, it's a good idea most to install most of the modules anyway).
85
86COPYRIGHT
87 This Program is free software. You can change or redistribute it under
88 the same condition as Perl itself.
89
90 Copyright (c) 2002, Janek Schleicher, <bigj@kamelfreund.de>
91
92AUTHOR
93 Janek Schleicher, <bigj@kamelfreund.de>
94
95SEE ALSO
96 Tie::Pick Data::Random Algorithm::Numerical::Sample
97