Shuffling an array randomly

KevinADC 0 Tallied Votes 161 Views Share

Use the List::Util module. I believe List::Util is a core module starting with perl 5.8. For older versions of perl you may need to install the module. See the module documentation for more details: List::Util

use List::Util 'shuffle';
my @deck = (1..52);
my @shuffled_deck = shuffle(@deck);