http://www.perlmonks.org?node_id=890741


in reply to randomising file order returned by File::Find

  1. Push the filenames into a list
  2. shuffle the list
  3. process the elements on the list.
use File::Find; use List::Util qw(shuffle); my @files; find({wanted => sub { push @files, $File::Find::name }, follow => 1}, +$somedir); @files = shuffle @files; process_file($_) for @files;