Shuffling an array randomly UserPageVisits:143 active 80 80 DaniWeb 561 60 2006-08-28T13:23:41+00:00 https://www.daniweb.com/programming/software-development/code/216775/shuffling-an-array-randomly

Shuffling an array randomly

KevinADC

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

143 Views
About the Author
code snippet
use List::Util 'shuffle';
my @deck = (1..52);
my @shuffled_deck = shuffle(@deck);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.