in reply to random file selection
If you need to select a subset of a specified size, then you could do something like this. (Note: You probably don't need the glob if your on *nix.
#! perl -slw use strict; use vars qw[$N]; $N ||= 30; die 'No path specified' unless @ARGV; my @files = glob $ARGV[0]; my $r; $r = rand(@files) and @files[$_,$r] = @files[$r,$_] for 0 .. $N; splice @files, $N; print for @files;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: random file selection
by Anonymous Monk on Jun 11, 2003 at 16:20 UTC | |
by BrowserUk (Patriarch) on Jun 11, 2003 at 17:02 UTC | |
by Anonymous Monk on Jun 13, 2003 at 20:29 UTC | |
by BrowserUk (Patriarch) on Jun 13, 2003 at 20:44 UTC | |
by Anonymous Monk on Jun 13, 2003 at 20:35 UTC | |
|
Re: Re: random file selection
by revdiablo (Prior) on Jun 11, 2003 at 22:03 UTC |