To get a random item from a set in Perl, you can use the List::Util module's shuffle function.
In this example,
@mySet
containing elements.shuffle
function from List::Util.use List::Util qw(shuffle);
my @mySet = ('Apple', 'Banana', 'Orange', 'Mango');
my @shuffledSet = shuffle(@mySet);
my $randomItem = $shuffledSet[0];
print "Random item from set: $randomItem\n";
Random item from set: Mango
In this tutorial, we learned How to get a Random Item in a Set in Perl language with well detailed examples.