#! perl -slw use strict; use List::Util qw[ shuffle ]; ## omit the glob if your shell expands wildcards for you. BEGIN{ @ARGV = shuffle map glob, @ARGV } my @temps; open $temps[ $_ ], '>', "tmp/$_.tmp" for 0 .. 99; while( <> ) { print { $temps[ rand 100 ] } $_; } seek $temps[ $_ ], 0, 0 for 0 .. 99; open FINAL, '>', "randomised.all" or die $!; for my $in ( shuffle @temps ) { while( <$in> ) { print FINAL; } close $in; } close FINAL;