in reply to randomly selecting files

Have a look at Math::Combinatorics which will allow you to calculate all of the combinations. You can then do what you like with the results.

#! /usr/bin/perl # use strict; use warnings; use Math::Combinatorics; my @files; push @files, "file$_" foreach (1..36); my $c = Math::Combinatorics->new( count => 3, data => \@files); while (my @combo = $c->next_combination()) { my %combins; @combins{@combo}=(); my @leftovers = grep {!exists($combins{$_})} @files; print "Choose: @combo\tLeave: @leftovers\n";}

update: Obviously you would populate the @files array using a glob or similar. If your files aren't large you could pre-read them into memory.