Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl 如何在不使用循环的情况下生成具有随机值的数组?_Perl - Fatal编程技术网

Perl 如何在不使用循环的情况下生成具有随机值的数组?

Perl 如何在不使用循环的情况下生成具有随机值的数组?,perl,Perl,如何在Perl中生成一个包含100个随机值的数组,而不使用循环 我必须避免所有类型的循环,比如“for”,foreach“,while。这是我在实验室做的练习。我找不到解决这个问题的方法,因为我是Perl新手 在C语言中,生成这个数组非常容易,但我不知道如何在Perl中实现 my @rand = map { rand } ( 1..100 ); 但地图只是一个装饰精美的环 如果您需要执行100次某项操作,则需要使用某种迭代结构。生成数据: my @array = map { rand() }

如何在Perl中生成一个包含100个随机值的数组,而不使用循环

我必须避免所有类型的循环,比如“for”,foreach“,while。这是我在实验室做的练习。我找不到解决这个问题的方法,因为我是Perl新手

在C语言中,生成这个数组非常容易,但我不知道如何在Perl中实现

my @rand = map { rand } ( 1..100 );
但地图只是一个装饰精美的环

如果您需要执行100次某项操作,则需要使用某种迭代结构。

生成数据:

my @array = map { rand() } (0..99);
打印数据以显示结果正确:

print "$_\n" foreach (@array);

生成循环是隐藏的(没有可见的循环关键字-只有一个函数/运算符)。

没有比这更简单的了

my @rands = (rand, rand, rand, rand, rand, rand, rand, rand, rand, rand,
  rand, rand, rand, rand, rand, rand, rand, rand, rand, rand, rand,
  rand, rand, rand, rand, rand, rand, rand, rand, rand, rand, rand,
  rand, rand, rand, rand, rand, rand, rand, rand, rand, rand, rand,
  rand, rand, rand, rand, rand, rand, rand, rand, rand, rand, rand,
  rand, rand, rand, rand, rand, rand, rand, rand, rand, rand, rand,
  rand, rand, rand, rand, rand, rand, rand, rand, rand, rand, rand,
  rand, rand, rand, rand, rand, rand, rand, rand, rand, rand, rand,
  rand, rand, rand, rand, rand, rand, rand, rand, rand, rand, rand,
  rand, rand);
按@array,rand; 按@array,rand; #…再重复98次
虽然copy'n'paste示例很新颖,也提到了map/foreach替代方案,但我认为有一种方法尚未讨论。使用递归(隐式循环)将需要方法调用和简单的“if”语句:no for/grep/map/等。它可能会产生副作用或无副作用

由于这是作业,我将把实现留给海报

快乐编码

顺便说一句:还没有人发布正则表达式解决方案;-)

很高兴看到一些更具创新性的解决方案!:-)

递归:

sub fill_rand {
 my ($array, $count) = @_;
   if ($count >= 1) {
   unshift @$array, rand();
   fill_rand ($array, --$count);
 }
}

my @array;
fill_rand (\@array, 100);
#!/usr/bin/perl
use warnings; use strict;

my @rands;
my $i=1;

sub push_rand {
    return if $#rands>=99;
    push @rands, rand;
    push_rand();
}

push_rand();

for (@rands) { print "$i: $_\n"; $i++; }
“尾部呼叫优化”版本:

使用eval:

my @array;
eval("\@array = (" . ("rand(), " x 100) . ");");
如果您假设我的perl是随机的(而不是毫无根据的假设),那么您可以使用perl文件本身作为随机数据源:

open FILE, __FILE__ or die "Can't open " . __FILE__ . "\n";
my $string;
read FILE, $string, 100;
close FILE;
my @array = map { ord } split //, $string;
当然,每次都会得到相同的结果,但这对于测试很有用。

对于娱乐价值:

在EOL为单个字符的系统上工作的方法: 使用正则表达式:
手动复制和粘贴100次
rand
调用真的很简单: 基于文件I/O的解决方案,不需要
/dev/random
: 这是一个递归字符串
eval
版本:
!/usr/bin/perl
使用严格;使用警告;使用autodie;
本地$/=\1;

根据侦听器的请求打开我的$F,“,这是一个非纯正则表达式解决方案:

$s="D" x 100; 
$s=~s/D/rand()." "/ge; 
@s=split(/ /,$s);
纯正则表达式溶液
双正则表达式解决方案 这:

无循环地产生这样的结果:

0.636939813223766 0.349175195300148 0.692949079946754 0.230945990743699 0.61873698433654 0.940179094890468 0.435165707624346 0.721205126535175 0.0322560847184015 0.91310500801842 0.31596325316222 0.788125484008084 0.802964232426337 0.417745170032291 0.155032810595454 0.146835982654117 0.181850358582611 0.932543988687968 0.143043972615896 0.415793094159206 0.576503681784647 0.996621492832261 0.382576007897708 0.090130958455255 0.39637315568709 0.928066985272665 0.190092542303415 0.518855656633185 0.797714758118492 0.130660731025571 0.534763929837762 0.136503767441518 0.346381958112605 0.391661401050982 0.498108766062398 0.478789295276393 0.882380841033143 0.852353540653993 0.90519922056134 0.197466335156797 0.820753004050889 0.732284103461893 0.738124358455405 0.250301496672911 0.88874926709342 0.0647566487704268 0.733226696403218 0.186469206795884 0.837423290530243 0.578047704593843 0.776140208497122 0.375268613243982 0.0128391627800006 0.872438613450569 0.636808174464274 0.676851978312946 0.192308731231467 0.401619465269903 0.977516959116411 0.358315250197542 0.726835710856381 0.688046044314845 0.870742340556202 0.58832098735666 0.552752229159754 0.170767637182252 0.683588677743852 0.0603160539059857 0.892022266162105 0.10206962926371 0.728253338154527 0.800910562860132 0.628613236438159 0.742591620029089 0.602839705915397 0.00926448179027517 0.182584549347883 0.53561587562946 0.416667072500555 0.479173194613729 0.78711818598828 0.017823873107119 0.824805088282755 0.302367196288522 0.0677539595682397 0.509467036447674 0.906839536492864 0.804383046648944 0.716848992363769 0.450693083312729 0.786925293921154 0.078886787987166 0.417139859647296 0.9574382550514 0.581196777508975 0.75882630076142 0.391754631502298 0.370189654004974 0.80290625532508 0.38016959549288

递归数值函数解法 实际上,如果打印阵列,会执行以下操作:

@_=(*100=sub{$_[0]?(rand,(*{--$_[0]}=*{$_[0]})->(@_)):()})->($==100);
第二种解决方案现在可以很容易地获得不同数量的随机数,因为按照上面的分配,您可以做到如下几点:

 print for @42=42->($==42);
是的,这确实是一个名为
42()


解释 第一个正则表达式解决方案依赖于Unicode巧妙的两个匹配字符的大小写。添加空格和注释可能(也可能不)更容易理解:

use 5.010;

say for &{

    sub  { "\U\x{fb01}\x{fb03}" =~ m((?mix-poop)

#include <stdlib.h>
#include <unistd.h>
#include <regex.h>
#include "perl.h"
#include "utf8.h"

#ifndef BROKEN_UNICODE_CHARCLASS_MAPPINGS

                        .{0,2}

                .{0,3}          .{0,3}

                        .{0,4}

#define rand() (random()<<UTF_ACCUMULATION_SHIFT^random()&UTF_CONTINUATION_MASK)
       +(?{ $_  [++$#_] = rand() || rand() || UTF8_TWO_BYTE_LO (*PERL_UNICODE)
#else                                                          (*PRUNE)
#define FAIL                                                   (*ACCEPT)
          })                                                   (*FAIL)
#endif                                                         (*COMMIT)
    )poop || pop                                            @{ (*_{ARRAY})     }
    ;#;                                                     @{ (*SKIP:REGEX)   }
                                                            @{ (*_{ARRAY})     }
    }
}
需要将变量作为参数传递是因为自动递减需要左值。我这样做是因为我不想说两次
$\u0]-1
,也不想有任何命名的临时变量。这意味着您可以这样做:

$N = 100;
print for $N->($N);
完成后,
$N==0
,因为传递隐式引用语义

对于重复的代价,您可以放松左值参数的需要

(*100 = sub { $_[0]
                 ? ( rand, ( *{ $_[0] - 1 } = *{ $_[0] } )->( $_[0] - 1 ) )
                 : ( )
            }
)->( 100 );
现在您不再需要左值参数,因此可以编写:

print for 100->(100);
获取所有100个随机数。当然,您还有100个其他数字函数,因此您可以通过以下任何方式获取随机数列表:

@vi = 6->(6); 
@vi = &6( 6);

$dozen = 12;

@dozen         =  $dozen->($dozen);
@baker's_dozen = &$dozen(++$dozen);

@_ = 100;
print &0;  # still a hundred of 'em
(对不起,这些愚蠢的颜色。一定是个臭虫。)


我相信这会把一切都清理干净。☺

使用匿名子对象和递归:

use strict;
use warnings;

my @foo;
my $random;
($random = sub {
        push @{$_[0]}, rand;
        return if @{$_[0]} == $_[1];
        goto \&$random;
})->(\@foo, 100);

print "@foo\n";
print scalar @foo, "\n";
使用计算goto,对于所有fortran风扇:

use strict;
use warnings;

sub randoms {
        my $num = shift;
        my $foo;
        CARRYON:
                push @$foo, rand;
                # goto $#{$foo} < 99 ? 'CARRYON' : 'STOP';
                goto ( ('CARRYON') x 99, 'STOP' )[$#$foo];
        STOP:
                return @$foo;
}

my @foo = randoms(100);
print "@foo\n";
print scalar(@foo)."\n";

map
在此用作单个值的主题化符,使其免于循环状态:

my @rand = map&$_($_),sub{@_<=100&&goto&{push@_,rand;$_[0]};shift;@_};
或使用eval,无变量赋值,无外部状态,一个或多个子:

my @rand = eval'sub{@_<100?eval((caller 1)[6]):@_}->(@_,rand)';
没有perl循环:

#!/usr/bin/perl
use strict;
use warnings;

@ARGV=q!echo 'int rand(void); int printf(const char *format, ...); int main(void) { int i; for(i=0;i<100;++i)printf("%d\\\\n",rand()); return 0; }' | gcc -x c - && ./a.out |!;
chomp(my @array=<>);
!/usr/bin/perl
严格使用;
使用警告;

@ARGV=q!echo'int rand(void);int printf(const char*format,…);int main(void){int i;for(i=0;i太糟糕了,大多数解决方案都集中在非循环部分,而忽略了随机数部分:

use LWP::Simple;

my @numbers = split /\s+/, #/ Stackoverflow syntax highlighting bug 
    get( 'http://www.random.org/integers/?num=100&min=1&max=100&col=1&base=10&format=plain&rnd=new' );
这是Tom一直在等待看到的疯狂,但我让它稍微疯狂一点。此解决方案将问题简化为
rand
调用:

my @numbers = rand( undef, 100 ); # fetch 100 numbers
Normal通常需要0或1个参数。我给了它一个新的原型,允许第二个参数记录返回的数字

但是请注意real
rand
的一些差异。这是不连续的,因此可用的数字要少得多,并且它的上限是包含的。此外,由于此参数包含两个参数,因此它与期望使用real参数的程序不兼容,因为这样的语句在每个参数中的解析方式不同:

 my @array = rand 5, 5;
然而,这里的
CORE::GLOBAL::rand()
并没有什么特别之处。您不必更换内置的。您可以这样做只是有点不舒服

我在那里留下了一些
print
语句,这样您就可以看到它工作了:

BEGIN {
    my @buffer;

    my $add_to_buffer = sub {
        my $fetch = shift;
        $fetch ||= 100;
        $fetch = 100 if $fetch < 100;
        require LWP::Simple;
        push @buffer, split /\s+/, #/ Stackoverflow syntax highlighting bug
          LWP::Simple::get(
            "http://www.random.org/integers/?num=$fetch&min=1&max=100&col=1&base=10&format=plain&rnd=new"
            );
        };

    my $many = sub ($) {
        print "Fetching $_[0] numbers\n";
        $add_to_buffer->($_[0]) if @buffer < $_[0];
        my @fetched = splice @buffer, 0, $_[0], ();
        my $count = @fetched;
        print "Fetched [$count] @fetched\n";
        @fetched
        };

    *CORE::GLOBAL::rand = sub (;$$) {
        my $max = $_[0] || 1; # even 0 is 1, just like in the real one
        my $fetch = $_[1] || ( wantarray ? 10 : 1 );
        my @fetched = map { $max * $_ / 100 } $many->( $fetch );
        wantarray ? @fetched : $fetched[-1];
        };
    }

my @rand = rand(undef, 5);
print "Numbers are @rand\n\n";

@rand = rand(87);
print "Numbers are @rand\n\n";

$rand = rand(undef, 4);
print "Numbers are $rand\n\n";

$rand = rand();
print "Numbers are $rand\n\n";

$rand = rand(undef, 200);
print "Numbers are $rand\n\n";
开始{
我的@buffer;
我的$add\u to\u buffer=sub{
我的$fetch=shift;
$fetch | |=100;
如果$fetch<100,则$fetch=100;
要求LWP::简单;
push@buffer,split/\s+/,#/Stackoverflow语法突出显示错误
LWP::Simple::get(
"http://www.random.org/integers/?num=$fetch&min=1&max=100&col=1&base=10&format=plain&rnd=new“
);
};
我的$many=sub($){
打印“正在提取$\u0]个数字\n”;
$add_to_buffer->($u0]),如果@buffer<$0];
my@fetched=splice@buffer,0,$[0],();
我的$count=@fetched;
打印“已提取[$count]@Fetched\n”;
@吸引
};
*核心::全局::兰德=子(;$$){
我的$max=$([0]| | 1;#甚至0
(*100 = sub { $_[0]
                ? ( rand, ( *{ --$_[0] } = *{ $_[0] } )->(@_) )
                : ( )
            }
)->( $= = 100 );
$N = 100;
print for $N->($N);
(*100 = sub { $_[0]
                 ? ( rand, ( *{ $_[0] - 1 } = *{ $_[0] } )->( $_[0] - 1 ) )
                 : ( )
            }
)->( 100 );
print for 100->(100);
@vi = 6->(6); 
@vi = &6( 6);

$dozen = 12;

@dozen         =  $dozen->($dozen);
@baker's_dozen = &$dozen(++$dozen);

@_ = 100;
print &0;  # still a hundred of 'em
use strict;
use warnings;

my @foo;
my $random;
($random = sub {
        push @{$_[0]}, rand;
        return if @{$_[0]} == $_[1];
        goto \&$random;
})->(\@foo, 100);

print "@foo\n";
print scalar @foo, "\n";
use strict;
use warnings;

sub randoms {
        my $num = shift;
        my $foo;
        CARRYON:
                push @$foo, rand;
                # goto $#{$foo} < 99 ? 'CARRYON' : 'STOP';
                goto ( ('CARRYON') x 99, 'STOP' )[$#$foo];
        STOP:
                return @$foo;
}

my @foo = randoms(100);
print "@foo\n";
print scalar(@foo)."\n";
use strict;
use warnings;

my @bar = sub {  return &{$_[0]} }->
(
        sub {
                push @{$_[1]}, rand;
                goto \&{$_[0]}
                        unless scalar(@{$_[1]}) == $_[2];
                return @{$_[1]};
        },
        [],
        100
);

print "@bar\n";
print scalar(@bar), "\n";
# I rolled a die, honestly!
my @random = (5, 2, 1, 3, 4, 3, 3, 4, 1, 6,
              3, 2, 4, 2, 1, 1, 1, 1, 4, 1,
              3, 6, 4, 6, 2, 6, 6, 1, 4, 5,
              1, 1, 5, 6, 6, 5, 1, 4, 1, 2,
              3, 1, 2, 2, 6, 6, 6, 5, 3, 3,
              6, 3, 4, 3, 1, 2, 1, 2, 3, 3,
              3, 4, 4, 1, 5, 5, 5, 1, 1, 5,
              6, 3, 2, 2, 1, 1, 5, 2, 5, 3,
              3, 3, 5, 5, 1, 6, 5, 6, 3, 2,
              6, 3, 5, 6, 1, 4, 3, 5, 1, 2);
my @rand = map&$_($_),sub{@_<=100&&goto&{push@_,rand;$_[0]};shift;@_};
my @rand = sub{&{$_[0]}}->(sub{@_<=100&&goto&{(@_=(rand,@_))[-1]};pop;@_});
my @rand = do{local*_=sub{(push@_,rand)<100?goto&_:@_};&_};
my @rand = eval'sub{@_<100?eval((caller 1)[6]):@_}->(@_,rand)';
my @rand = map&$_,sub{(100^push@_,rand)?goto&$_:@_};
#!/usr/bin/perl
use strict;
use warnings;

@ARGV=q!echo 'int rand(void); int printf(const char *format, ...); int main(void) { int i; for(i=0;i<100;++i)printf("%d\\\\n",rand()); return 0; }' | gcc -x c - && ./a.out |!;
chomp(my @array=<>);
use LWP::Simple;

my @numbers = split /\s+/, #/ Stackoverflow syntax highlighting bug 
    get( 'http://www.random.org/integers/?num=100&min=1&max=100&col=1&base=10&format=plain&rnd=new' );
my @numbers = rand( undef, 100 ); # fetch 100 numbers
 my @array = rand 5, 5;
BEGIN {
    my @buffer;

    my $add_to_buffer = sub {
        my $fetch = shift;
        $fetch ||= 100;
        $fetch = 100 if $fetch < 100;
        require LWP::Simple;
        push @buffer, split /\s+/, #/ Stackoverflow syntax highlighting bug
          LWP::Simple::get(
            "http://www.random.org/integers/?num=$fetch&min=1&max=100&col=1&base=10&format=plain&rnd=new"
            );
        };

    my $many = sub ($) {
        print "Fetching $_[0] numbers\n";
        $add_to_buffer->($_[0]) if @buffer < $_[0];
        my @fetched = splice @buffer, 0, $_[0], ();
        my $count = @fetched;
        print "Fetched [$count] @fetched\n";
        @fetched
        };

    *CORE::GLOBAL::rand = sub (;$$) {
        my $max = $_[0] || 1; # even 0 is 1, just like in the real one
        my $fetch = $_[1] || ( wantarray ? 10 : 1 );
        my @fetched = map { $max * $_ / 100 } $many->( $fetch );
        wantarray ? @fetched : $fetched[-1];
        };
    }

my @rand = rand(undef, 5);
print "Numbers are @rand\n\n";

@rand = rand(87);
print "Numbers are @rand\n\n";

$rand = rand(undef, 4);
print "Numbers are $rand\n\n";

$rand = rand();
print "Numbers are $rand\n\n";

$rand = rand(undef, 200);
print "Numbers are $rand\n\n";
#!/usr/bin/perl
use warnings; use strict;

my @rands;
my $i=1;

sub push_rand {
    return if $#rands>=99;
    push @rands, rand;
    push_rand();
}

push_rand();

for (@rands) { print "$i: $_\n"; $i++; }
#!/usr/bin/perl
open my $slf, $0;
undef $/;
(my $s = <$slf>) =~ s/./rand()." "/eggs;
$s .= rand();
#!/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;
use strict;
use warnings;

package Tie::RandArray;
use Tie::Array;
our @ISA = ('Tie::StdArray');
sub FETCH  { rand; }

package main;
my @rand;
my $object = tie @rand, 'Tie::RandArray';
$#rand=100;
my @a= @somearray;
warn "@a";
#!/usr/bin/perl

rand1();

$idx = 1;

foreach $item (@array) {
    print "$idx - $item\n";
    $idx++;
}

exit;



sub rand1() {
    rand2();
    rand2();
    rand2();
    rand2();
}

sub rand2() {
    rand3();
    rand3();
    rand3();
    rand3();
    rand3();
}

sub rand3() {
    push @array, rand;
    push @array, rand;
    push @array, rand;
    push @array, rand;
    push @array, rand;
}
#!/usr/bin/perl
                                      ''=~('('.'?'
           .'{'.(                   '`'|'%').("\["^
        '-').('`'|                '!').('`'|',').'"'
 .'\\'.'$'.  ("\`"|              ',').('`'|')').('`'|
'-').'='.('^'^("\`"|            '/')).('^'^('`'|'.')).
('^'^('`'|'.')).';'.(          '!'^'+').('`'|'&').('`'
  |'/').('['^')').'('        .'\\'.'$'.'='.'='.(('^')^(
       '`'|'/')).';'.      '\\'.'$'.'='.'<'.'='.'\\'.'$'
      .('`'|(',')).(     '`'|')').('`'|'-').';'.'+'."\+".
     '\\'.'$'.('=').   ')'.'\\'.'{'.('['^'+').('['^"\.").(
    '['^'(').("\`"|   '(').('{'^'[').'\\'.'@'.'='.','.("\{"^
    '[').('['^')').  ('`'|'!').('`'|'.').('`'|'$').'\\'.'}'.(
    '!'^'+').'\\'.  '$'.'='.'='.('^'^('`'|'/')).';'.('!'^'+')
    .('`'|('&')).(  '`'|'/').('['^')').('{'^'[').'('.'\\'.'@'.
    '='.')'.('{'^'[').'\\'.'{'.('!'^'+').('*'^'#').('['^'+').(
    '['^')').('`'|')').('`'|'.').('['^'/').('{'^'[').'\\'.'"'.(
     '['^')').('`'|'!').('`'|'.').('`'|'$').('{'^'[').'\\'.'$'.
     '='.('{'^'[').('`'|'/').('`'|'&').('{'^'[').'\\'.'$'.("\`"|
      ',').('`'|')').('`'|'-').'='.'\\'.'$'.'_'.'\\'.'\\'.(('`')|
       '.').'\\'.'"'.';'.('!'^'+').('*'^'#').'\\'.'$'.'='.'+'.'+'
        .';'.('!'^'+').('*'^'#').'\\'.'}'.'"'.'}'.')');$:='.' ^((
         '~'));$~='@'|'(';$^=')'^'[';$/='`'|'.';$,='('^"\}";  $\=
          '`'|'!';$:=')'^'}';$~='*'|'`';$^='+'^'_'; $/="\&"|  '@'
            ;$,='['&'~';$\=','^'|';$:='.'^"\~";$~=  '@'|'('   ;$^
             =')'^ '[';$/='`'|'.';$,='('^"\}";$\=   '`'|'!'   ;$:
                   =')'^'}';$~='*'|'`';$^=('+')^    '_';$/=   '&'
                   |'@';$,=    '['&'~';$\ ="\,"^     '|';$:   =(
                   ('.'))^     "\~";$~=   ('@')|     '(';$^  =(
                   (')'))^     "\[";$/=   "\`"|       "\.";  (
                   ($,))=      '('^'}';   ($\)         ='`'
                   |"\!";     $:=(')')^   '}';         ($~)
                    ='*'|     "\`";$^=    '+'^         '_';
                    ($/)=     '&'|'@'     ;$,=         '['&
                    '~';     $\=','       ^'|'         ;$:=
                    '.'^     '~'          ;$~=         '@'|
                    '(';      $^=         ')'          ^((
                    '['        ));       $/=           '`'
                    |((         '.'     ));            $,=
                    '('          ^((   '}'              ))
                    ;(             ($\))=               ((
                    ((              '`'))               ))
                    |+             "\!";$:=             ((
                   ')'            ))^+ "\}";            $~
                  =((           '*'))|  '`';           $^=
                 '+'^         "\_";$/=   '&'          |'@'
               ;($,)=                                ('[')&
             "\~";$\=                               ','^'|'
#!/usr/bin/perl
                                                  ''=~('(?{'.
                                                  ('`'|'%').(
                                                  '['^"\-").(
                                                  '`'|"\!").(
                                                  '`'|(',')).
                                                  '"\\$'.('`'
                                                    |',').(
                                                    '`'|')'
                                                    ).('`'|
                                                    ('-')).
                                                    ('=').(
                                                   '^'^('`'|
                                                   ('/'))).(
                                                   '^'^('`'|
                                                   ('.'))).(
                                                  '^'^(('`')|
                                                  '.')).';'.(
                                                 '!'^'+').('`'
                                                 |'&').(('`')|
                                                '/').('['^')').
                                                '(\\$=='.('^'^(
                                               '`'|'/')).';\\$='
                                              .'<=\\$'.('`'|',').
                                             ('`'|')').('`'|"\-").
                                            ';++\\$=)\\{'.('['^'+')
                                           .('['^'.').('['^'(').('`'
                                          |'(').('{'^'[').'\\@'.('`'|
                                          '!').('['^')').('['^"\)").(
                                          '`'|'!').('['^'"').','.('{'
                                          ^'[').('['^')').('`'|'!').(
                                          '`'|'.').('`'|"\$").'\\}'.(
'!'^'+').'\\$'.('`'|')').'='.("\^"^(      '`'|'/')).';'.('!'^('+')).(
 '`'|'&').('`'|'/').('['^')').('{'^       '[').'(\\@'.('`'|'!').('['^
   ')').('['^')').('`'|'!').('['^         '"').')'.('{'^"\[").'\\{'.(
    '!'^'+').('*'^'#').('['^'+')          .('['^')').('`'|')').("\`"|
      '.').('['^'/').('{'^'[')            .'\\"'.('['^')').('`'|'!').
       ('`'|'.').('`'|"\$").(             '{'^'[').'\\$'.('`'|"\)").(
         '{'^'[').('`'|'/')               .('`'|'&').('{'^'[').'\\$'.
          ('`'|',').("\`"|                ')').('`'|'-').'=\\$_\\\\'.
            ('`'|('.')).                  '\\";'.('!'^'+').('*'^'#').
             '\\$'.('`'                   |')').'++;'.('!'^'+').('*'^
               "\#").                     '\\}"})');$:='.'^'~';$~='@'
                |'('                      ;$^=')'^'[';$/='`'|"\.";$,=
                '('^                      '}';$\='`'|'!';$:=')'^"\}";
                ($~)                      ='*'|'`';$^='+'^'_';$/='&'|
                '@';                      $,='['&'~';$\=','^('|');$:=
                '.'^                      '~';$~='@'|'(';$^=')'^"\[";
                ($/)                      ='`'|'.';$,='('^'}';$\='`'|
                '!';                      $:=')'^'}';$~='*'|('`');$^=
                '+'^                      '_';$/='&'|'@';$,='['&"\~";
                ($\)                      =','^'|';$:='.'^'~';$~='@'|
                '(';                      $^=')'^'[';$/='`'|('.');$,=
                '('^                      '}';$\='`'|'!';$:=')'^"\}";
                ($~)                      ='*'|'`';$^='+'^'_';$/='&'|
'@';$,='['&'~';$\=','^'|';$:='.'^'~'      ;$~='@'|'(';$^=')'^"\[";$/=
'`'|'.';$,='('^'}';$\='`'|'!';$:=')'      ^'}';$~='*'|'`';$^='+'^'_';
#!/usr/bin/perl
           '?'                          =~(
         '('.'?'                      ."\{".(
        '`'   |'%'  ).('['^"\-").(  '`'|   '!'
         ).('`'|',').    '"'.    '\\'.('$').(
         '`'|(',')).(    '`'|    ')').(('`')|
        ((  '-')   )).    +(    '`'   |')'  ).
       (((    '['   ))^+  ((  '/')   )).    '='
      .('^'^   ('`'|'/')) .( '^'^("\`"|   '.')).
     +(     '^'^('`'|'.')).';'.('!'^"\+").     ((
 '\\')).'$'.('`'|'#').('`'|'/').('['^'.').('`'|'.').(
'['^  '/').'='.  (('^')^(    '`'|'/')  ).(';').(  '!'^
'+'    ).('['^    '(').(      ('[')^    "\.").(    '`'
|'"'  ).(('{')^  ('[')).(    '['^'+')  .('['^'.'  ).+(
 '['^'(').('`'|'(').'_'.('['^')').('`'|'!').('`'|'.')
     .(     '`'|'$').('{'^'[').'\\'."\{".(     ((
      '!'))^   '+').('{'^ (( ('[')))).(   ('{')^
       '['    ).(   '{'^  ((  '[')   )).    (((
        ((  '{')   )))    ^+    '['   ).+(  ((
         '['))^')').(    '`'|    '%').(('[')^
         '/').(('[')^    '.')    .('['^')').(
        '`'   |'.'  ).('{'^"\[").(  '`'|   ')'
         ).('`'|                      "\&").(
           '{'                          ^((
           '['                          )))
         .'\\'.+                      '$'.'#'
        .+(   '`'|  '!').('['^')')  .''.   (((
         '['))^')').(    '`'|    '!').(('[')^
         '"').('_').(    '`'|    '/').(('`')|
        ((  '&')   )).    ((    '_'   )).(  ((
       '['    ))^   ')')  .(  '`'|   '!'    ).(
      ('`')|   '.').('`'| (( ('$')))).(   ('[')^
     ((     '('))).'>'.'\\'.'$'.('`'|',').     +(
 '`'|')').('`'|'-').('`'|')').('['^'/').';'.('!'^'+')
.''.  ('{'^'[')  .(('{')^    ('[')).(  '{'^'[').  ('{'
^((    '['))).    ("\["^      '+').(    '['^'.'    ).(
'['^  '(').('`'  |"\(").(    '{'^'[')  .'\\'.'@'  .''.
 ('`'|'!').('['^')').('['^')').('`'|'!').('['^('"')).
     ((     '_')).('`'|'/').('`'|'&').'_'.     +(
      ('[')^   ')').('`'| (( ('!')))).(   ('`')|
       '.'    ).(   '`'|  ((  '$')   )).    (((
        ((  '[')   )))    ^+    '('   ).((  ((
         ',')))).('{'    ^'['    ).('['^')').
         ('`'|"\!").(    '`'|    '.').(('`')|
        '$'   ).((  ';')).('!'^'+'  ).+(   '{'
         ^'[').(                      '{'^'['
           ).(                          '{'
           ^((                          '['
         ))).''.                      (('{')^
        '['   ).+(  '['^'+').('['^  '.')   .+(
         '['^('(')).(    '`'|    '(').('_').(
         '['^(')')).(    '`'|    '!').(('`')|
        ((  '.')   )).    +(    '`'   |'$'  ).
       '('    .((   ')')  ).  ';'.   (((    '!'
      ))^'+'   ).'\\'.'}' .( '!'^'+').(   ('!')^
     ((     '+'))).('!'^'+').('['^('(')).(     ((
 '['))^'.').('`'|'"').('{'^'[').('['^'+').('['^')').(
'`'|  ')').('`'  |"\.").(    '['^'/')  .'_'.('['  ^')'
).(    '`'|'%'    ).('`'      |'#').    (('[')^    '.'
).+(  '['^')').  ('['^'('    ).("\`"|  ')').('['  ^'-'
 ).('`'|'%').('{'^'[').'\\'.'{'.('!'^'+').('{'^'[').(
     ((     '{'))^'[').('{'^'[').('{'^'[')     .+
      '\\'.+   '$'.("\["^ (( '/'))).'='   .('['^
       '+'    ).(   '`'|  ((  '/')   )).    (((
        ((  '[')   )))    ^+    '+'   ).+(  ((
         '{'))^"\[").    '\\'    .'@'.'_'.';'
         .('!'^'+').(    '*'^    '#').(('[')^
        '+'   ).+(  '['^')').('`'|  ')')   .+(
         '`'|'.'                      ).('['^
           '/'                          ).(
           '{'                          ^((
         '['))).                      ('\\').
        '"'   .''.  ('['^')').('`'  |'!'   ).(
         '`'|('.')).(    '`'|    '$').(('{')^
         '[').('\\').    '$'.    ('`'|"\#").(
        ((  '`')   )|+    ((    '/'   ))).  +(
       '['    ^((   '.')  ))  .''.   (((    '`'
      ))|'.'   ).('['^'/' ). ('{'^'[').   ("\`"|
     ((     '/'))).('`'|'&').('{'^'[').''.     ((
 '\\')).'$'.('`'|',').('`'|')').('`'|'-').('`'|')').(
'['^  '/').'='.  '\\'.'$'    .(('[')^  '/').'\\'  .''.
(((    '\\')))    .('`'|      "\.").    ('\\').    '"'
.';'  .('!'^'+'  ).("\*"^    '#').''.  '\\'.'$'.  ('`'
 |'#').('`'|'/').('['^'.').('`'|'.').('['^'/').('+').
     ((     '+')).';'.('!'^'+').('*'^'#').     +(
      ('[')^   '+').('['^ (( (')')))).(   ('`')|
       ')'    ).(   '`'|  ((  '.')   )).    (((
        ((  '[')   )))    ^+    '/'   ).((  ((
         '_')))).('['    ^')'    ).('`'|'%').
         ('`'|"\#").(    '['^    '.').(('[')^
        ')'   ).+(  '['^'(').('`'|  ')')   .+(
         '['^'-'                      ).('`'|
           '%'                          ).+
           '('                          .((
         '\\')).                      '@'.'_'
        .((   ')')  ).('{'^"\[").(  '`'|   ')'
         ).('`'|'&').    ('{'    ^'[').('(').
         '\\'.'@'.'_'    .')'    .';'.(('!')^
        ((  '+')   )).    ((    (((   '\\'  ))
       )))    .((   '}')  ).  ('!'   ^((    '+'
      ))).+(   '!'^'+').( (( '['))^'+')   .('['^
     ((     '.'))).('['^'(').('`'|'(').'_'     .(
 '['^')').('`'|'!').('`'|'.').('`'|'$').'('.')'.';'.(
'['^  '+').('['  ^"\)").(    '`'|')')  .('`'|'.'  ).+(
'['    ^"\/").    "\_".(      ('[')^    "\)").(    '`'
|'%'  ).(('`')|  ('#')).(    '['^'.')  .('['^')'  ).+(
 '['^'(').('`'|')').('['^'-').('`'|'%').'('.'\\'.'@'.
     +(     '`'|'!').('['^')').('['^')').(     ((
      '`'))|   '!').('['^ (( '"'))).'_'   .('`'|
       '/'    ).(   '`'|  ((  '&')   )).    '_'
        .(  '['^   ')'    ).    (((   '`')  )|
         '!').(('`')|    '.')    .('`'|'$').(
         '['^'(').')'    .';'    .'"'.'}'.')'
        );(   $:)=  '.'^'~';$~='@'  |'('   ;$^
         =(')')^                      '[';#;#
           ;#;                          #;#
rand 1 of 100=0.625268682212667
rand 2 of 100=0.30160434879096
...
rand 100 of 100=0.584811321826528
sub two{ my $y=shift; ($y->(), $y->()) }
sub five{my $y=shift; ($y->(), $y->(), $y->(), $y->(), $y->()) } 
my @array = five(sub{five(sub{two(sub{two(sub{rand()})})})});