in reply to Re: oneliner for selecting multiple values from array
in thread oneliner for selecting multiple values from array

A little more generally you could:

my @arr = ('A'..'Z'); my $n = 2 ; my $combo = join '', map { $arr[rand @arr] } (1..$n) ; print $combo . "\n";
which will give you any length string you like.

Whatever you do, don't do:

my @arr = ('A'..'Z'); my $n = 2 ; my $combo = $arr[rand @arr] x $n ; print $combo . "\n";
however plausible it might appear :-(

Of course it doesn't work, you say, it's obvious... However, I have, ahem, a friend who once (once was enough):

my @arr = ([]) x $count ;
and had a lot of fun (tm) working out why their program behaved as oddly as it did !