You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by pengyh <pe...@mail.de> on 2022/08/17 01:07:48 UTC
shuffle a array
in my modperl app I want to shuffle an array. such as this method in ruby,
irb(main):005:0> array
=> [1, 2, 3, 4]
irb(main):006:0> array.shuffle
=> [1, 4, 3, 2]
do you know how to achieve it in perl?
Thanks.
Re: shuffle a array
Posted by Artur Penttinen <ar...@yandex.ru>.
sort { int(rand 3)-1 } @array
17.08.2022, 04:42, "Jacques Deguest" <ja...@deguest.jp>:
> I think this kind of question is not modperl specific and best suited for
> StackOverlow -> [<https://stackoverflow.com/questions/13416337/what-s-the-
> best-way-to-shuffle-an-array-in-
> perl>](https://stackoverflow.com/questions/13416337/what-s-the-best-way-to-
> shuffle-an-array-in-perl)
>
>
>
> On 2022/08/17 10:07, pengyh wrote:
>
>
>> in my modperl app I want to shuffle an array. such as this method in ruby,
>
> irb(main):005:0> array
> => [1, 2, 3, 4]
> irb(main):006:0> array.shuffle
> => [1, 4, 3, 2]
>
>
> do you know how to achieve it in perl?
>
> Thanks.
>
>
>
>
\--
wbw, artur
Re: shuffle a array
Posted by Jacques Deguest <ja...@deguest.jp>.
I think this kind of question is not modperl specific and best suited
for StackOverlow ->
<https://stackoverflow.com/questions/13416337/what-s-the-best-way-to-shuffle-an-array-in-perl>
On 2022/08/17 10:07, pengyh wrote:
> in my modperl app I want to shuffle an array. such as this method in
> ruby,
>
> irb(main):005:0> array
> => [1, 2, 3, 4]
> irb(main):006:0> array.shuffle
> => [1, 4, 3, 2]
>
>
> do you know how to achieve it in perl?
>
> Thanks.