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;
In reply to Re: random file selection
by BrowserUk
in thread random file selection
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |