in reply to Dice roll chances
My 2˘: perl -E 'say scalar map {1..$_} map {int (rand(50)+1)} (1..5);'
Update:
I guess i'll never learn it to read specs right.
Did you mean this?
If so, this should work: perl -E 'say scalar map {1..$_} map {int (rand(50)+1)} (1..5) for 1..5'
Update 2:
If you want to use the numbers only once, this should work:
#!/usr/bin/env perl use strict; use warnings; use feature qw (say); my @n = ( 1 .. 50 ); # ad libitum: # open( my $urandom, "</dev/urandom" ) or die $!; # read( $urandom, $_, 4 ); # close $urandom; # srand( unpack( "L", $_ ) ); # for ( my $i = @n ; --$i ; ) { # my $j = int( rand( $i + 1 ) ); # next if $i == $j; # @n[ $i, $j ] = @n[ $j, $i ]; # } say scalar map { 1 .. $_ } map { splice( @n, int( rand(@n) ), 1 ) } ( 1 .. 5 ) for 1 .. 5; __END__
To be honest: i didn't test it very thoroughly ;-(
Best regards, Karl
«The Crux of the Biscuit is the Apostrophe»
perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help
|
|---|