# @lines is the old unshuffled array(list of indexes to your Tie::File array) @lines = 0..51; #for you the sequence would be 1..(scalar @YourTieArray) @shuffled = (); # an empty array $numlines = 52; #scalar @yourTieArray again while ($numlines > 0) { push(@shuffled, splice(@lines, (rand $numlines), 1)); $numcards--; } # @shuffled contains the shuffled lines, @lines is empty