How to generate an array with random values, without using a loop?

后端 未结 24 2165
逝去的感伤
逝去的感伤 2020-12-13 19:23

How can I generate an array in Perl with 100 random values, without using a loop?

I have to avoid all kind of loops, like \"for\", foreach\", while. This is my exerc

24条回答
  •  悲&欢浪女
    2020-12-13 19:54

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    
    my $x = 99;
    my @rands = (rand,(*x=sub{rand,(map{*x->($x,sub{*x})}($x)x!!--$x)})->($x,*x));
    
    use feature 'say';
    say for @rands;
    

提交回复
热议问题