in reply to shuffle a text file

What happened when you ran your code? What happens when you run this simplified version:

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "sub shuffle { my $array = shift; my $i; for ($i = @$array; --$i; ) { my $j = int rand ($i+1); next if $i == $j; @$array[$i,$j] = @$array[$j,$i]; } } ;; my @lines = qw(foo bar baz quux); my @reordered = shuffle(\@lines); dd \@reordered; " [0]
Why does the  @reordered array always end up with a single element of 0? (Update: What do you get if you dump  @lines after shuffling, and why?)