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

Another way using the core module List::Util
use List::Util qw(shuffle); my @arr = ('A'..'Z'); my $combo = join '', (shuffle(@arr))[0..1]; print "$combo\n";

Replies are listed 'Best First'.
Re^3: oneliner for selecting multiple values from array (shuffle)
by massa (Hermit) on Nov 18, 2008 at 15:21 UTC
    Your solution, toolic, is nice but not equivalent to the original script; the original could choose two elements that are equal; yours can't... ;-)
    []s, HTH, Massa (κς,πμ,πλ)
      Fair enough -- I guess I focussed more on the description rather than the code of the OP:
      Is there a way to select multiple values from the array without repetition?
      I interpreted the description as meaning "unique" elements of the array, which my solution will provide. So, there seems to be a discrepancy between the OP description and code.

        Indeed, the OP continues with:

        For instance how to properly do the following:

        which rather implied to me that the code may not have been "proper". i.e. it can select multiple elements with repetition.


        Perl reduces RSI - it saves typing