in reply to Pick random file and print
If you want to make it faster, consider switching to mod_perl. There isn't much else you can do here.my ($dir, $file, $rnd) = ('/home/test/_html/index/', undef, undef); opendir DIR, $dir or die $!; while (1){ $file = readdir DIR; last unless defined $file; next unless $file =~ /^index\.[^.]+\.html/; $rnd = $file; last if rand(10) > 5; } closedir DIR; die "No files found\n" unless defined $rnd; open IN, "<$rnd" or die $!; print while (<IN>); close IN;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Pick random file and print
by kappa (Chaplain) on May 07, 2002 at 14:19 UTC |